Kannel 1.4.1 User's Guide

Open Source WAP and SMS gateway

Andreas Fink

Chairman & CTO
Global Networks Inc.

 
http://www.smsrelay.com
http://www.gni.ch

Bruno Rodrigues

 

http://litux.org/bruno

Stipe Tolj

Chief Technology Scientist
Wapme Systems AG

 

http://www.wapme.de

Aarno Syvänen

Chief MMS Developer
Global Networks Inc.

 

http://www.gni.ch

Alexander Malysh

Lars Wirzenius

Gateway architect
former Wapit Ltd

Kalle Marjola

Senior Software Engineer
Enpocket

 

http://www.enpocket.com

Abstract

This document describes how to install and use Kannel, the Open Source WAP and SMS Gateway originally developed by Wapit Ltd (now out of business) and now being developed further by the open source community, namely the Kannel Group.


Table of Contents
1. Introduction
Overview of WAP
Overview of WAP Push
Overview of SMS
Features
WAP
WAP Push
SMS
Requirements
2. Installing the gateway
Getting the source code
Finding the documentation
Compiling the gateway
Installing the gateway
Using pre-compiled binary packages
Installing Kannel from RPM packages
Installing Kannel from DEB packages
3. Using the gateway
Configuring the gateway
Configuration file syntax
Inclusion of configuration files
Core configuration
Running Kannel
Starting the gateway
Command line options
Kannel statuses
HTTP administration
4. Setting up a WAP gateway
WAP gateway configuration
Wapbox group
Running WAP gateway
Checking whether the WAP gateway is alive
5. Setting up MSISDN provisioning for WAP gateway
RADIUS accounting proxy configuration
RADIUS-Acct configuration
Using the MSISDN provisioning on HTTP server side
6. Setting up a SMS Gateway
Required components
SMS gateway configuration
SMS centers
Nokia CIMD 1.37 and 2.0
CMG UCP/EMI 4.0 and 3.5
SMPP 3.4
Sema Group SMS2000 OIS 4.0, 5.0 and 5.8
SM/ASI (for CriticalPath InVoke SMS Center 4.x)
GSM modem
Fake SMSC
HTTP-based relay and content gateways
MT to MO direction switching
Using multiple SMS centers
Feature checklist
External delivery report (DLR) storage
Internal DLR storage
MySQL DLR storage
LibSDB DLR storage
Oracle 8i/9i DLR storage
PostgreSQL DLR storage
DLR database field configuration
SMSBox configuration
Smsbox group
Smsbox routing inside bearerbox
SMS-service configurations
How sms-service interprets the HTTP response
SendSMS-user configurations
Over-The-Air configurations
Setting up more complex services
Running SMS gateway
Using the HTTP interface to send SMS messages
Using the HTTP interface to send OTA configuration messages
7. Setting up Push Proxy Gateway
Configuring ppg core group, for push initiator (PI) interface
Configuring PPG user group variables
Finishing ppg configuration
Running a push proxy gateway
An example using HTTP SMSC
An example of minimum SI document
An example push (tokenized SI) document
Default network and bearer used by push proxy gateway
Push related Kannel headers
Requesting SMS level delivery reports for WAP pushes
Routing WAP pushes to a specific smsc
8. Using SSL for HTTP
Using SSL client support
Using SSL server support for the administration HTTP interface
Using SSL server support for the sendsms HTTP interface
Using SSL server support for PPG HTTPS interface
9. SMS Delivery Reports
10. Getting help and reporting bugs
A. Upgrading notes
From 1.2.x or 1.3.1 to 1.3.2 and later
B. Using the fake WAP sender
C. Using the fake SMS center
Setting up fakesmsc
Compiling fakesmsc
Configuring Kannel
Running Kannel with fakesmsc connections
Starting fake SMS center
D. Setting up a test environment for Push Proxy Gateway
Creating push content and control document for testing
Starting necessary programs
Using Nokia Toolkit as a part of a developing environment
Testing PAP protocol over HTTPS
E. Setting up a dial-up line
Analog modem
ISDN terminal
F. Regular Expressions
Syntax and semantics of the regex configuration parameter
How-to setup the regex-parameters
Regex and non-regex-parameters
Performance issues
Examples
Example 1: core-configuration
Example 3: smsc-configuration
Example 4: sms-service-configuration
G. Log files
Bearerbox Access Log
Log rotation
Glossary
Bibliography
List of Tables
3-1. Core Group Variables
3-2. Kannel Command Line Options
3-3. Kannel HTTP Administration Commands
4-1. Wapbox Group Variables
5-1. RADIUS-Acct Group Variables
6-1. SMSC Group Variables
6-2. SMSC driver features
6-3. SMSC driver internal features
6-4. MySQL Connection Group Variables
6-5. DLR Database Field Configuration Group Variables
6-6. Smsbox Group Variables
6-7. Smsbox-route Group Variables
6-8. SMS-Service Group Variables
6-9. Parameters (Escape Codes)
6-10. X-Kannel Headers
6-11. X-Kannel Post Headers
6-12. SendSMS-User Group Variables
6-13. OTA Setting Group Variables
6-14. OTA Bookmark Group Variables
6-15. SMS Push reply codes
6-16. SMS Push (send-sms) CGI Variables
6-17. OTA CGI Variables
7-1. PPG core group configuration variables
7-2. PPG user group configuration variables
7-3. Kannel headers used by PPG
C-1. Fakesmsc command line options
D-1. Test_ppg's command line options
D-2. Test_ppg's configuration file directives
List of Figures
1-1. Logical position of WAP gateway (and PPG)between a phone and a content server.
1-2. Logical position of SMS gateway between a phone and a content server.

Chapter 1. Introduction

This chapter introduces WAP and SMS in general terms, and explains the role of the gateway in WAP and SMS, outlining their duties and features. It also explains why the Kannel project was started in the first place, and why it is open source.

With hundreds of millions of mobile phones in use all over the world, the market for services targeted at mobile users is mind-bogglingly immense. Even simple services find plenty of users, as long as they're useful or fun. Being able to get news, send e-mail or just be entertained wherever you are is extremely attractive to many.

The hottest technology for implementing mobile services is WAP, short for Wireless Application Protocol. It lets the phone act as a simple web browser, but optimizes the markup language, scripting language, and the transmission protocols for wireless use. The optimized protocols are translated to plain old HTTP by a WAP gateway.

Kannel is an open source WAP gateway. It attempts to provide this essential part of the WAP infrastructure freely to everyone so that the market potential for WAP services, both from wireless operators and specialized service providers, will be realized as efficiently as possible.

Kannel also works as an SMS gateway for GSM networks. Almost all GSM phones can send and receive SMS messages, so this is a way to serve many more clients than just those using a new WAP phone.

In addition, Kannel operates as Push Proxy Gateway , or PPG, making possible for content servers to send data to the phones. This is a new type of WAP service, and have many interesting applications. Usually servers know whether some data is new, not the users.

Kannel's quality has been recognized on March 7, 2001 when it was certified by Wap Forum as the first WAP 1.1 gateway in the world.

Greater quality recognition are the quantity of companies using Kannel to successful connect to a variety of SMSC protocols in lots of countries.

Open Source is a way to formalize the principle of openness by placing the source code of a product under a Open Source compliant software license. The BSD license was chosen over other Open Source licenses by the merit of placing the least amount of limitations on what a third party is able to do with the source code. In practice this means that Kannel is going to be a fully-featured WAP implementation and compatible with the maximum number of bearers with special emphasis on SMSC compatibility. The Kannel project was founded by Wapit Ltd in June, 1999.


Overview of WAP

WAP, short for Wireless Application Protocol, is a collection of various languages and tools and an infrastructure for implementing services for mobile phones. Traditionally such services have worked via normal phone calls or short textual messages (e.g., SMS messages in GSM networks). Neither are very efficient to use, nor very user friendly. WAP makes it possible to implement services similar to the World Wide Web.

Unlike marketers claim, WAP does not bring the existing content of the Internet directly to the phone. There are too many technical and other problems for this to ever work properly. The main problem is that Internet content is mainly in the form of HTML pages, and they are written in such way that they require fast connections, fast processors, large memories, big screens, audio output and often also fairly efficient input mechanisms. That's OK, since they hopefully work better for traditional computers and networks that way. However, portable phones have very slow processors, very little memory, abysmal and intermittent bandwidth, and extremely awkward input mechanisms. Most existing HTML pages do not work on mobiles phones, and never will.

WAP defines a completely new markup language, the Wireless Markup Language (WML), which is simpler and much more strictly defined than HTML. It also defines a scripting language, WMLScript, which all browsers are required to support. To make things even simpler for the phones, it even defines its own bitmap format (Wireless Bitmap, or WBMP).

HTTP is also too inefficient for wireless use. However, by using a semantically similar binary and compressed format it is possible to reduce the protocol overhead to a few bytes per request, instead of the usual hundreds of bytes. Thus, WAP defines a new protocol stack to be used. However, to make things simpler also for the people actually implementing the services, WAP introduces a gateway between the phones and the servers providing content to the phones.

Figure 1-1. Logical position of WAP gateway (and PPG)between a phone and a content server.

The WAP gateway talks to the phone using the WAP protocol stack, and translates the requests it receives to normal HTTP. Thus content providers can use any HTTP servers and utilize existing know-how about HTTP service implementation and administration.

In addition to protocol translations, the gateway also compresses the WML pages into a more compact form, to save on-the-air bandwidth and to further reduce the phone's processing requirements. It also compiles WMLScript programs into a byte-code format. Latest WAP specifications defines some additional conversions that Kannel is starting to implement, like multipart/form-data, multipart/mixed or MMS content conversion.

Kannel is not just a WAP gateway. It also works as an SMS gateway. Although WAP is the hot and technically superior technology, SMS phones exist in huge numbers and SMS services are thus quite useful. Therefore, Kannel functions simultaneously as both a WAP and an SMS gateway.


Overview of WAP Push

Previous chapter explained pull mode of operation: the phone initiates the transaction. There is, however, situations when the server (called in this context a push initiator) should be the initiator, for instance, when it must send a mail notification or a stock quote. For this purpose WAP Forum defined WAP Push.

Push is an application level service, sitting on the top of existing WAP stack. It defines two protocols, OTA and PAP. OTA is a ligthweigth protocol speaking with WAP stack (to be more specific, with WSP), PAP speaks with the push initiator. It defines three kind of XML documents, one for the push data itself and another for protocol purposes (these are called pap document or push control documents).

The server does not simply send push content to the phone, the user would surely not accept, for instance, interrupting of a voice call. Instead it sends a specific XML document, either Service Indication or Service Loading. These inform the user about the content become available, and it is displayed only when it is not interrupting anything. It contains an URL specifying the service and a text for user describing the content. Then the user can decide does he accept push or not.

The push content is send ed to the phones over SMS, but the content is fetched by the phone over IP bearer, for instance CSD or GPRS. Because Push Proxy Gateway tokenises SI and SL documents, it may fit one SMS message (if not, it is segmented for transfer).

Using two bearers seems to be an unnecessary complication. But quite simply, phones currently operate this way. Push over GPRS can only simplify matters.


Overview of SMS

SMS, short messaging service, is a way to send short (160 character) messages from one GSM phone to another. It can also be used to send regular text as well as advanced content like operator logos, ringing tones, business cards and phone configurations.

SMS services are content services initiated by SMS message to certain (usually short) phone number, which then answers with requested content, if available.

When SMS services are used, the client (mobile terminal) sends an SMS message to certain number, usually a very short specialized number, which points to specific SMS center responsible for that number (plus possibly many others). This SMS center then sends the message onward to specified receiver in intra- or Internet, using an SMS center specific protocol. For example, a Nokia SMS center uses CIMD protocol.

As practically every different kind of SMS center uses different protocol, an SMS gateway is used to handle connections with SMS centers and to relay them onward in an unified form. Kannel's biggest feature is to abstract each SMSC protocol to a well-known HTTP protocol, simplifying services deployment.

Figure 1-2. Logical position of SMS gateway between a phone and a content server.

An SMS gateway can also be used to relay SMS messages from one GSM network to another, if the networks do not roam messages normally.

Kannel works as an SMS gateway, talking with many different kind of SMS centers, and relaying the messages onward to content providers, as HTTP queries. Content providers then answer to this HTTP query and the answer is sent back to mobile terminal, with appropriate SMS center connection using SMS center specific protocol.

In addition to serving mobile originated (MO) SMS messages Kannel also works as an SMS push gateway - content providers can request Kannel to send SMS messages to terminals. Kannel then determines the correct SMS center to relay the SMS message and sends the SMS message to that SMS center, again using SMS center specific protocol. This way the content provider does not need to know any SMS center specific protocol, just unified Kannel SMS sending interface.


Features

WAP

  • Fully compliant with WAP 1.1 specification

  • Already implements some WAP 1.2 and even WAP 2.0 features.


WAP Push

  • Supports WAP Push SI and SL

  • ...


SMS

  • Supports a variety of SMSC protocols, namely:

    • CMG's UCP/EMI 4.0 and 3.5

    • ...

  • Full support for MO and MT messages


Requirements

Kannel is being developed on Linux systems, and should be fairly easy to export to other Unix-like systems. However, we don't yet support other platforms, due to lack of time, although it should be working without major problems on Windows (through Cygwin), Solaris and FreeBSD.

Kannel requires the following software environment:

  • C compiler and libraries for ANSI C, with normal Unix extensions such as BSD sockets and related tools. (GNU's GCC tool-chain is recommended)

  • The Gnome XML library (known as gnome-xml and libxml), version 2.2.5 or newer. See http://xmlsoft.org/xml.html.

    If you are installing it from your distribution's packages, you'll need libxml2-dev in addition to run-time libxml2 package libraries.

  • GNU Make.

  • An implementation of POSIX threads (pthread.h).

  • GNU Bison 1.28, if you want to modify the WMLScript compiler (a pre-generated parser is included for those who just want to compile Kannel).

  • DocBook processing tools: DocBook style-sheets, jade, jadetex, etc; see README, section `Documentation', for more information (pre-formatted versions of the documentation are available, and you can compile Kannel itself even without the documentation tools).

  • GNU autoconf, if you want to modify the configuration script.

Hardware requirements are fluffier. Some informal benchmarkings have shown that with a reasonably fast PC architecture (e.g. 400MHz Pentium II with 128MB RAM), SMS performance's bottleneck is always on the SMSC side, even for example with multiple connections summing a pipeline with 400 msg/sec. We haven't benchmarked Kannel yet on WAP side, so there are no hard numbers.


Chapter 2. Installing the gateway

This chapter explains how the gateway can be installed, either from a source code package or by using a pre-compiled binary version. The goal of this chapter is to get the gateway compiled and all the files in the correct places; the next chapter will explain how the gateway is configured.

Note: If you are upgrading from a previous version, please look at Appendix A for any important information.


Getting the source code

The source code to Kannel is available for download at http://www.kannel.org/download.shtml. It is available in various formats and you can choose to download either the latest release version or the daily snapshot of the development source tree for the next release version, depending on whether you want to use Kannel for production use or to participate in the development.

If you're serious about development, you probably want to use CVS, the version control system used by the Kannel project. This allows you to participate in Kannel development much more easily than by downloading the current daily snapshot and integrating any changes you've made every day. CVS does that for you. (See the Kannel web site for more information on how to use CVS.)


Finding the documentation

The documentation for Kannel consists of three parts:

  1. User's Guide, i.e., the one you're reading at the moment.

  2. Architecture and Design, in doc/arch or at http://www.kannel.org/arch.shtml

  3. The README and various other text files in the source tree.

You can also find general information on Kannel's website and information about existing problems at our bugtracker.

We intend to cover everything you need to install and use Kannel is in User's Guide, but the guide is still incomplete in this respect. Similarly, the Architecture and Design document should tell you everything you need to know to dive into the sources and quickly make your own modifications. It's not a replacement for actually reading the source code, but it should work as a map to the source code. The README is not supposed to be very important, nor contain much information. Instead, it will just point at the other documentation.


Compiling the gateway

If you are using Kannel on a supported platform, or one that is similar enough to one, compiling Kannel should be trivial. After you have unpacked the source package of your choose, or after you have checked out the source code from CVS, enter the following commands:

        ./configure
        make
	
The configure script investigates various things on your computer for the Kannel compilation needs, and writes out the Makefile used to compile Kannel. make then runs the commands to actually compile Kannel.

If either command writes out an error message and stops before it finishes its job, you have a problem, and you either need to fix it yourself, if you can, or report the problem to the Kannel project. See Chapter 10 for details.

For detailed instruction on using the configuration script, see file INSTALL. That file is a generic documentation for configure. Kannel defines a few additional options:

  • --with-defaults=type Set defaults for the other options. type is either speed or debug. The default is speed. speed options is equivalent to --with-malloc=native --disable-assertions, while debug is --with-malloc=checking --enable-assertions.

  • --disable-docs (default is --enable-docs) Use this option if you don't have DocBook installed and/or you want to save some time and CPU cycles. Pre-generated documentation is available on Kannel's site. Default behavior is to build documentation, b.e., converting the User Guide and the Architecture Guide from the DocBook markup language to PostScript and HTML if DocBook is available.

  • --enable-drafts (default is --disable-drafts) When building documentation, include the sections marked as draft.

  • --enable-debug (default is --disable-debug) Enable non-reentrant development time debugging of WMLScript compiler.

  • --disable-localtime (default is --enable-localtime) Write log file time stamps in GMT, not in local time.

  • --enable-assertions / --disable-assertions Turn on or off runtime assertion checking. enable makes Kannel faster, but gives less information if it crashes. Default value is dependent on --with-defaults.

  • --with-malloc=type Select memory allocation module to use: type is native, checking, or slow. For production use you probably want native. The slow module is more thorough than checking, but much slower. Default value is dependent on --with-defaults.

  • --enable-mutex-stats Produce information about lock contention.

  • --enable-start-stop-daemon Compile the start-stop-daemon program.

  • --enable-pam Enable using PAM for authentication of sendsms users for smsbox.

  • --with-mysql Enable using MySQL libraries for DBPool and DLR support.

  • --with-mysql-dir=DIR Where to look for MySQL libs and header files. DIR points to the installation of MySQL.

  • --with-sdb Enable using LibSDB libraries for dlr support.

  • --with-oracle Enable using Oracle OCI-Libraries for Oracle 8i/9i DBPool and DLR support.

  • --with-oracle-includes=DIR Where to look for Oracle OCI-Header files.

  • --with-oracle-libs=DIR Where to look for Oracle OCI-Library files.

You may need to add compilations flags to configure:

	CFLAGS='-pthread' ./configure
	
The above, for instance, seems to be required on FreeBSD. If you want to develop Kannel, you probably want to add CFLAGS that make your compiler use warning messages. For example, for GCC:
	CFLAGS='-Wall -O2 -g' ./configure
	
(You may, at your preference, use even stricter checking options.)


Installing the gateway

After you have compiled Kannel, you need to install certain programs in a suitable place. This is most easily done by using make again:

	make bindir=/path/to/directory install
	
Replace /path/to/directory with the pathname of the actual directory where the programs should be installed. The programs that are installed are (as filenames from the root of the source directory):

gw/bearerbox
gw/smsbox
gw/wapbox

The version number of the gateway is added to the file names during installation. This makes it easier to have several versions installed, and makes it easy to go back to an older version if the new version proves problematic.

Kannel consists of three programs called boxes: the bearer box is the interface towards the phones. It accepts WAP and SMS messages from the phones and sends them to the other boxes. The SMS box handles SMS gateway functionality, and the WAP box handles WAP gateway functionality. There can be several SMS boxes and several WAP boxes running and they don't have to run on the same host. This makes it possible to handle much larger loads.


Using pre-compiled binary packages

Installing Kannel from RPM packages

This chapter explains how to install, upgrade and remove Kannel binary RPM packages.

Before you install Kannel, check that you have libxml2 installed on your system:

	rpm -q libxml2
	

Installing Kannel

1. Download the binary RPM packet from the Kannel web site.

2. Install the RPM package:

	rpm -ivh kannel-VERSION.i386.rpm
	

Upgrading Kannel

1. Download the binary RPM packet from the Kannel web site.

2. Upgrade the RPM package:

	rpm -Uvh kannel-VERSION.i386.rpm
	

Removing Kannel

1. Remove the RPM package:

	rpm -e kannel
	

After you have installed Kannel from the RPM packages you should now be able to run the Kannel init.d script that will start Kannel as a WAP gateway. Run the script as root.

	/etc/rc.d/init.d/kannel start
	

To stop the gateway just run the same script with the stop parameter.

	/etc/rc.d/init.d/kannel stop
	

If Kannel is already running and you just want to quickly stop and start the gateway,e.g.to set a new configuration option, run the script with the restart parameter.

	/etc/rc.d/init.d/kannel restart
	

If you want Kannel to run as a daemon, you need to add a symbolic link to the Kannel script from the runlevel you want Kannel to run in. E.g. to run Kannel in runlevel 5 add symbolic links to /etc/rc.d/rc5.d/.

	cd /etc/rc.d/rc5.d/
	ln -s ../init.d/kannel S91kannel
	ln -s ../init.d/kannel K91kannel
	

To run Kannel as a SMS gateway you need to edit the configuration file which is at /etc/kannel/kannel.conf. In kannel's documentation directory (/usr/share/doc/kannel) there is an example file called examples/smskannel.conf. It has some basic examples of the configuration groups needed to run Kannel as a SMS gateway. For more detailed information please see examples/kannel.conf in the same directory for a commented complete example, and read the section "SMS gateway configuration" later in this same document.

The logging is disabled by default and you can enable it from the kannel.conf file. Just add the log-file option to the group of which box you want to log.

The documentation will be installed at /usr/doc/kannel-VERSION/ or /usr/share/doc/kannel-VERSION/ depending on if you used the RedHat 6.x or a 7.x or newer package.

In the Kannel documentation directory there is a HTML file called control.html. It is an example file that shows how to use the Kannel HTTP administration interface. It also has a template for sending SMS messages.


Installing Kannel from DEB packages

This chapter explains how to install, upgrade and remove Kannel binary DEB packages.

Kannel's packages are available on main Debian repository (http://packages.debian.org/kannel) although that version may be out-of-sync with latest Kannel version.

Before you install Kannel, check that you have libxml2 installed on your system:

	dpkg -l libxml2
	

Installing or upgrading Kannel from Debian or Kannel repository

1. Install or upgrade the package:

	apt-get install kannel
	

See http://kannel.org/download.shtml#debian_repository for informations about kannel repository sources.list

Installing or upgrading Kannel from a file

1. Download the binary DEB packet from the Kannel web site.

2. Log in as root:

	su -
	

3. Install or upgrade the DEB package:

	dpkg -i kannel-VERSION.deb
	

Removing Kannel

1. Log in as root:

2. Remove the package keeping configuration files:

	dpkg --remove kannel
	

3. Remove the package completely:

	dpkg --purge kannel
	

After you have installed Kannel from the DEB packages you should now be able to run the Kannel init.d script that will start Kannel as a WAP gateway. Run the script as root.

	/etc/init.d/kannel start
	

To stop the gateway just run the same script with the stop parameter.

	/etc/init.d/kannel stop
	

If Kannel is already running and you just want to quickly stop and start the gateway,e.g.to set a new configuration option, run the script with the restart parameter.

	/etc/init.d/kannel restart
	

If you don't want Kannel to run as a daemon, run:

	update-rc.d -f kannel remove
	

If you want to restore Kannel running as a daemon, you need to add a symbolic link to the Kannel script from the runlevel you want Kannel to run in. E.g. to run Kannel in default runlevel, just run:

	update-rc.d kannel defaults
	

Kannel package starts by default with a wapbox daemon. To activate smsbox or select which box you want to start, edit /etc/default/kannel and comment/uncomment START_xxxBOX.

To run Kannel as a SMS gateway you need to edit the configuration file which is at /etc/kannel/kannel.conf. In /usr/share/docs/kannel/examples/ there are example files. They have some basic examples of the configuration groups needed to run Kannel as a SMS gateway. For more detailed information please read the section "SMS gateway configuration" later in this same document.

The documentation will be installed at /usr/share/doc/kannel/.

In the Kannel documentation directory there is a html file called control.html. It is an example file that shows how to use the Kannel HTTP administration interface. It also has a template for sending SMS messages.

Additionally to kannel-VERSION.deb, there's now an optional kannel-docs-VERSION.deb with documentation (userguide et al) and a kannel-extras-VERSION.deb with contrib and test stuff.

If you want to test development version, use the packages called kannel-devel-*.deb.


Chapter 3. Using the gateway

This chapter explains how the gateway core, bearerbox, is configured and used. It covers the configuration file, keeping an eye on the gateway while it is running, and using the HTTP interface to control the gateway.

After this chapter there is distinct chapter for each kind of gateway use: WAP gateway, SMS gateway and WAP Push proxy. These chapters explain the configuration and other aspects of gateway of that type.

You can configure your Kannel to be only a WAP or a SMS gateway, or to be both at the same time. You just need to read each chapter and combine all configurations.

There is only one configuration file for all parts of Kannel, although when Kannel is distributed to several hosts some lines from the configuration file can be removed in some hosts.


Configuring the gateway

The configuration file can be divided into three parts: bearerbox configurations, smsbox configurations and wapbox configurations. Bearerbox part has one 'core' group and any used SMS center groups, while wapbox part has only one wapbox group. In smsbox part there is one smsbox group and then number of sms-service and sendsms-user groups.

Details of each part are in an appropriate section of this documentation. The 'core' group used by the bearerbox is explained in this chapter, while 'wapbox' part is in the next chapter and 'smsbox', 'smsc' (SMS center), 'sms-service' and 'sendsms-user' groups are in the SMS Kannel chapter.


Configuration file syntax

A configuration file consists of groups of configuration variables. Groups are separated by empty lines, and each variable is defined on its own line. Each group in Kannel configuration is distinguished with a group variable. Comments are lines that begin with a number sign (#) and are ignored (they don't, for example, separate groups of variables).

A variable definition line has the name of the variable, and equals sign (=) and the value of the variable. The name of the variable can contain any characters except whitespace and equals. The value of the variable is a string, with or without quotation marks () around it. Quotation marks are needed if the variable needs to begin or end with whitespace or contain special characters. Normal C escape character syntax works inside quotation marks.

Perhaps an example will make things easier to comprehend:

1    # A do-nothing service.
2    group = sms-service
3    keyword = nop
4    text = "You asked nothing and I did it!"
5
6    # Default service.
7    group = sms-service
8    keyword = default
9    text = "No services defined"
The above snippet defines the keyword nop for an SMS service, and a default action for situation when the keyword in the SMS message does not match any defined service.

Lines 1 and 6 are comment lines. Line 5 separates the two groups. The remaining lines define variables. The group type is defined by the group variable value.

The various variables that are understood in each type of configuration group are explained below.

Some variable values are marked as 'bool'. The value for variable can be like true, false, yes, no, on, off, 0 or 1. Other values are treated as 'true' while if the variable is not present at all, it is treated as being 'false'.

In order to make some configuration lines more readable you may use the delimiter '\' at the end of a line to wrap and concatenate the next line up to the current line. Here is an example:

1    # A group with a wrapped alias line
2    group = sms-service
3    keyword = hello
4    aliases = hallo;haalloo;\
5      heelloo;haelloo;healloo
5    text = "Hello world!"
The above example shows how a list for various alias keywords is wrapped to two lines using the line wrap delimiter. In order to use the delimiter '\' itself, you need to escape it via a prefixed '\' itself. So this is '\\' to escape the wrapping function and use the character in the string.


Inclusion of configuration files

A configuration file may contain a special directive called include to include other file or a directory with files to the configuration processing.

This allows to segment the specific configuration groups required for several services and boxes to different files and hence to have more control in larger setups.

Here is an example that illustrates the include statement :

group = core
admin-port = 13000
wapbox-port = 13002
admin-password = bar
wdp-interface-name = "*"
log-file = "/var/log/bearerbox.log"
log-level = 1
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"

include = "wapbox.conf"

include = "configurations"
Above is the main kannel.conf configuration file that includes the following wapbox.conf file with all required directives for the specific box, and a configurations directory which may include more files to include.
group = wapbox
bearerbox-host = localhost
log-file = "/var/log/wapbox.log"
log-level = 0
syslog-level = none
The above include statement may be defined at any point in the configuration file and at any inclusion depth. Hence you can cascade numerous inclusions if necessary.

At process start time inclusion of configuration files breaks if either the included file can not be opened and processed or the included file has been processed already in the stack and a recursive cycling has been detected.


Core configuration

Configuration for Kannel MUST always include a group for general bearerbox configuration. This group is named as 'core' in configuration file, and should be the first group in the configuration file.

As its simplest form, 'core' group looks like this:

group = core
admin-port = 13000
admin-password = f00bar
Naturally this is not sufficient for any real use, as you want to use Kannel as an SMS gateway, or WAP gateway, or both. Thus, one or more of the optional configuration variables are used. In following list (as in any other similar lists), all mandatory variables are marked with (m), while conditionally mandatory (variables which must be set in certain cases) are marked with (c).

Table 3-1. Core Group Variables

VariableValueDescription
group (m)core This is a mandatory variable
admin-port (m)port-number The port number in which the bearerbox listens to HTTP administration commands. It is NOT the same as the HTTP port of the local HTTP server, just invent any port, but it must be over 1023 unless you are running Kannel as a root process (not recommended)
admin-port-ssl (o)bool If set to true a SSL-enabled administration HTTP server will be used instead of the default insecure plain HTTP server. To access the administration pages you will have to use a HTTP client that is capable of talking to such a server. Use the "https://" scheme to access the secured HTTP server. Defaults to "no".
admin-password (m)string Password for HTTP administration commands (see below)
status-passwordstring Password to request Kannel status. If not set, no password is required, and if set, either this or admin-password can be used
admin-deny-ipIP-list These lists can be used to prevent connection from given IP addresses. Each list can have several addresses, separated with semicolons (';'). An asterisk ('*') can be used as a wild-card in a place of any ONE number, so *.*.*.* matches any IP.
admin-allow-ip
smsbox-port (c)port-number This is the port number to which the smsboxes, if any, connect. As with admin-port, this can be anything you want. Must be set if you want to handle any SMS traffic.
smsbox-port-ssl (o)bool If set to true, the smsbox connection module will be SSL-enabled. Your smsboxes will have to connect using SSL to the bearerbox then. This is used to secure communication between bearerbox and smsboxes in case they are in separate networks operated and the TCP communication is not secured on a lower network layer. Defaults to "no".
wapbox-port (c)port-number Like smsbox-port, but for wapbox-connections. If not set, Kannel cannot handle WAP traffic
wapbox-port-ssl (o)bool If set to true, the wapbox connection module will be SSL-enabled. Your wapboxes will have to connect using SSL to the bearerbox then. This is used to secure communication between bearerbox and wapboxes in case they are in separate networks operated and the TCP communication is not secured on a lower network layer. Defaults to "no".
box-deny-ipIP-list These lists can be used to prevent box connections from given IP addresses. Each list can have several addresses, separated with semicolons (';'). An asterisk ('*') can be used as a wild-card in place of any ONE number, so *.*.*.* matches any IP.
box-allow-ip
udp-deny-ipIP-list These lists can be used to prevent UDP packets from given IP addresses, thus preventing unwanted use of the WAP gateway. Used the same way as box-deny-ip and box-allow-ip.
udp-allow-ip
wdp-interface-name (c)IP or '*' If this is set, Kannel listens to WAP UDP packets incoming to ports 9200-9208, bound to given IP. If no specific IP is needed, use just an asterisk ('*'). If UDP messages are listened to, wapbox-port variable MUST be set.
log-filefilename A file in which to write a log. This in addition to stdout and any log file defined in command line. Log-file in 'core' group is only used by the bearerbox.
log-levelnumber 0..5 Minimum level of log-file events logged. 0 is for 'debug', 1 'info', 2 'warning, 3 'error' and 4 'panic' (see Command Line Options)
access-logfilename A file in which information about received/sent SMS messages is stored. Access-log in 'core' group is only used by the bearerbox.
access-log-cleanboolean Indicates if access-log will contain standard 'markers', which means the 'Log begins', 'Log ends' markers and the prefixed timestamp. This config directive should be set to 'true' if a custom logging format is desired without a prefixed default timestamp.
access-log-formatstring String defining a custom log file line format. May use escape codes as defined later on to substitute values of the messages into the log entry. If no custom log format is used the standard format will be: "%t %l [SMSC:%i] [SVC:%n] [ACT:%A] [BINF:%B] [from:%p] [to:%P] [flags:%m:%c:%M:%C:%d] [msg:%L:%b] [udh:%U:%u]"
unified-prefixprefix-list String to unify received phone numbers, for SMSC routing and to ensure that SMS centers can handle them properly. This is applied to 'sender' number when receiving SMS messages from SMS Center and for 'receiver' number when receiving messages from smsbox (either sendsms message or reply to original message). Format is that first comes the unified prefix, then all prefixes which are replaced by the unified prefix, separated with comma (','). For example, for Finland an unified-prefix "+358,00358,0;+,00" should do the trick. If there are several unified prefixes, separate their rules with semicolon (';'), like "+35850,050;+35840,040". Note that prefix routing is next to useless now that there are SMSC ID entries. To remove prefixes, use like "-,+35850,050;-,+35840,040".
white-listURL Load a list of accepted senders of SMS messages. If a sender of an SMS message is not in this list, any message received from the SMS Center is discarded. See notes of phone number format from numhash.h header file. NOTE: the system has only a precision of last 9 or 18 digits of phone numbers, so beware!
black-listURL As white-list, but SMS messages to these numbers are automatically discarded
store-filefilename A file in which any received SMS messages are stored until they are successfully handled. By using this variable, no SMS messages are lost in Kannel, but theoretically some messages can duplicate when system is taken down violently.
store-dump-freqseconds Approximated frequency how often the memory dump of current pending messages are stored to store-file, providing something has happened. Defaults to 10 seconds if not set.
http-proxy-hosthostname Enable the use of an HTTP proxy for all HTTP requests.
http-proxy-portport-number
http-proxy-exceptionsURL-list A list of excluded hosts from being used via a proxy. Separate each entry with space.
http-proxy-exceptions-regexUNIX regular expression Same as http-proxy-exceptions but match against UNIX regular expression.
http-proxy-usernameusername Username for authenticating proxy use, for proxies that require this.
http-proxy-passwordURL-list Password for authenticating proxy use, for proxies that require this.
ssl-client-certkey-file (c)filename A PEM encoded SSL certificate and private key file to be used with SSL client connections. This certificate is used for the HTTPS client side only, i.e. for SMS service requests to SSL-enabled HTTP servers.
ssl-server-cert-file (c)filename A PEM encoded SSL certificate file to be used with SSL server connections. This certificate is used for the HTTPS server side only, i.e. for the administration HTTP server and the HTTP interface to send SMS messages.
ssl-server-key-file (c)filename A PEM encoded SSL private key file to be used with SSL server connections. This key is associated to the specified certificate and is used for the HTTPS server side only.
ssl-trusted-ca-filefilename This file contains the certificates Kannel is willing to trust when working as a HTTPS client. If this option is not set, certificates are not validated and those the identity of the server is not proven.
dlr-storagetype Defines the way DLRs are stored. If you have build-in external DLR storage support, i.e. using MySQL you may define here the alternative storage type like 'mysql'. Supported types are: internal, mysql, oracle. By default this is set to 'internal'.
maximum-queue-lengthnumber of messages (deprecated, see sms-incoming-queue-limit).
sms-incoming-queue-limitnumber of messages Set maximum size of incoming message queue. After number of messages has hit this value, Kannel began to discard them. Value 0 means giving strict priority to outgoing messages. -1, default, means that the queue of infinite length is accepted. (This works with any normal input, use this variable only when Kannel message queues grow very long).
white-list-regexPOSIX regular expression A regular expression defining the set of accepted senders. See section on regular expressions for details.
black-list-regexPOSIX regular expression A regular expression defining the set of rejected senders. See section on regular expressions for details.
smsbox-max-pendingnumber of messages Maximum number of pending messages on the line to smsbox compatible boxes.
sms-resend-freqseconds Frequency for the SMS resend thread in which temporarily failed or queued messages will be resent. Defaults to 60 seconds.
sms-resend-retrynumber Maximum retry attempts for the temporarily failed messages. Defaults to -1, means: unlimited.

A sample more complex 'core' group could be something like this:

group = core
admin-port = 13000
admin-password = f00bar
status-password = sTat
admin-deny-ip = "*.*.*.*"
admin-allow-ip = "127.0.0.1;200.100.0.*"
smsbox-port = 13003
wapbox-port = 13004
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1;200.100.0.*"
wdp-interface-name = "*"
log-file = "kannel.log"
log-level = 1
access-log = "kannel.access"
unified-prefix = "+358,00358,0;+,00"
white-list = "http://localhost/whitelist.txt"


Running Kannel

To start the gateway, you need to start each box you need. You always need the bearer box, and depending on whether you want WAP and SMS gateways you need to start the WAP and SMS boxes. If you want, you can run several of them, but we'll explain the simple case of only running one each.


Starting the gateway

After you have compiled Kannel and edited configuration file for your taste, you can either run Kannel from command line or use supplied start-stop-daemon and run_kannel_box programs to use it as a daemon service (more documentation about that later).

If you cannot or do not know how to set up daemon systems or just want to test Kannel, you probably want to start it from command line. This means that you probably want to have one terminal window for each box you want to start (xterm or screen will do fine). To start the bearerbox, give the following command:

	./bearerbox -v 1 [config-file]
	
The -v 1 sets the logging level to INFO. This way, you won't see a large amount of debugging output (the default is DEBUG). Full explanation of Kannel command line arguments is below.

[config-file] is the name of the configuration file you are using with Kannel. The basic distribution packet comes with two sample configuration files, smskannel.conf and wapkannel.conf (in gw subdirectory), of which the first one is for testing out SMS Kannel and the second one for setting up a WAP Kannel. Feel free to edit those configuration files to set up your own specialized system.

After the bearer box, you can start the WAP box:

	./wapbox -v 1 [config-file]
	
or the SMS box:
	./smsbox -v 1 [config-file]
	
or both, of course. The order does not matter, except that you need to start the bearer box before the other boxes. Without the bearer box, the other boxes won't even start.


Command line options

Bearerbox, smsbox and wapbox each accept certain command line options and arguments when they are launched. These arguments are:

Table 3-2. Kannel Command Line Options

-v <level> Set verbosity level for stdout (screen) logging. Default is 0, which means 'debug'. 1 is 'info, 2 'warning', 3 'error' and 4 'panic'
--verbosity <level>
-D <places> Set debug-places for 'debug' level output.
--debug <places>
-F <file-name> Log to file named file-name, too. Does not overrun or affect any log-file defined in configuration file.
--logfile <file-name>
-V <level> Set verbosity level for that extra log-file (default 0, which means 'debug'). Does not affect verbosity level of the log-file defined in configuration file, not verbosity level of the stdout output.
--fileverbosity <level>
-S Start the system initially at SUSPENDED state (see below, bearerbox only)
--suspended
-I Start the system initially at ISOLATED state (see below, bearerbox only)
--isolated
-H Only try to open HTTP sendsms interface; if it fails, only warn about that, do not exit. (smsbox only)
--tryhttp
-g Dump all known config groups and config keys to stdout and exit.
--generate
-u <username> Change process user-id to the given.
--user <username>
-p <filename> Write process PID to the given file.
--pid-file <filename>
-d Start process as daemon (detached from a current shell session). Note: Process will change CWD (Current working directory) to /, therefore you should ensure that all paths to binary/config/config-includes are absolute instead of relative.
--daemonize
-P Start watcher process. This process watch a child process and if child process crashed will restart them automatically.
--parachute
-X <scriptname> Execute a given shell script or binary when child process crash detected. This option is usable only with --parachute/-P. Script will be executed with 2 arguments: scriptname 'processname' 'respawn-count'.
--panic-script <scriptname>

Kannel statuses

In Kannel, there are four states for the program (which currently directly only apply to bearerbox):

  1. Running. The gateway accepts, proceeds and relies messages normally. This is the default state for the bearerbox.

  2. Suspended. The gateway does not accept any new messages from SMS centers nor from UDP ports. Neither does it accept new sms and wapbox connections nor sends any messages already in the system onward.

  3. Isolated. In this state, the gateway does not accept any messages from external message providers, which means SMS Centers and UDP ports. It still processes any messages in the system and can accept new messages from sendsms interface in smsbox.

  4. Full. Gateway does not accept any messages from SMS centers, because maximum-queue-length is achieved.

  5. Shutdown. When the gateway is brought down, it does not accept any new messages from SMS centers and UDP ports, but processes all systems already in the system. As soon as any queues are emptied, the system exits

The state can be changed via HTTP administration interface (see below), and shutdown can also be initiated via TERM or INT signal from terminal. In addition, the bearerbox can be started already in suspended or isolated state with -S or -I command line option, see above.


HTTP administration

Kannel can be controlled via an HTTP administration interface. All commands are done as normal HTTP queries, so they can be easily done from command line like this:

	lynx -dump "http://localhost:12345/shutdown?password=bar"
	
...in which the '12345' is the configured admin-port in Kannel configuration file (see above). For most commands, admin-password is required as a argument as shown above. In addition, HTTP administration can be denied from certain IP addresses, as explained in configuration chapter.

Note that you can use these commands with WAP terminal, too, but if you use it through the same Kannel, replies to various suspend commands never arrive nor can you restart it via WAP anymore.

Table 3-3. Kannel HTTP Administration Commands

status or status.txt Get the current status of the gateway in a text version. Tells the current state (see above) and total number of messages relied and queuing in the system right now. Also lists the total number of smsbox and wapbox connections. No password required, unless status-password set, in which case either that or main admin password must be supplied.
status.html HTML version of status
status.xml XML version of status
status.wml WML version of status
store-status or store-status.txt Get the current content of the store queue of the gateway in a text version. No password required, unless status-password set, in which case either that or main admin password must be supplied.
store-status.html HTML version of store-status
store-status.xml XML version of store-status
suspend Set Kannel state as 'suspended' (see above). Password required.
isolate Set Kannel state as 'isolated' (see above). Password required.
resume Set Kannel state as 'running' if it is suspended or isolated. Password required.
shutdown Bring down the gateway, by setting state to 'shutdown'. After a shutdown is initiated, there is no other chance to resume normal operation. However, 'status' command still works. Password required. If shutdown is sent for a second time, the gateway is forced down, even if it has still messages in queue.
flush-dlr If Kannel state is 'suspended' this will flush all queued DLR messages in the current storage space. Password required.
start-smsc Re-start a single SMSC link. Password required. Additionally the smsc parameter must be given to identify which smsc-id should be re-started.
stop-smsc Shutdown a single SMSC link. Password required. Additionally the smsc parameter must be given (see above).
restart Re-start whole bearerbox, hence all SMSC links. Password required. Beware that you loose the smsbox connections in such a case.
loglevel Set Kannel log-level of log-files while running. This allows you to change the current log-level of the log-files on the fly.

Chapter 4. Setting up a WAP gateway

This chapter tells you how to set Kannel up as a WAP gateway.


WAP gateway configuration

To set up a WAP Kannel, you have to edit the 'core' group in the configuration file, and define the 'wapbox' group.

You must set following variables for the 'core' group: wapbox-port and wdp-interface-name. See previous chapter about details of these variables.

With standard distribution, a sample configuration file wapkannel.conf is supplied. You may want to take a look at that when setting up a WAP Kannel.


Wapbox group

If you have set wapbox-port variable in the 'core' configuration group, you MUST supply a 'wapbox' group.

The simplest working 'wapbox' group looks like this:

group = wapbox
bearerbox-host = localhost
There is, however, multiple optional variables for the 'wapbox' group.

Table 4-1. Wapbox Group Variables

VariableValueDescription
group (m)wapbox This is mandatory variable
bearerbox-host (m)hostname The machine in which the bearerbox is.
timer-freqvalue-in-seconds The frequency of how often timers are checked out. Default is 1
http-interface-nameIP address If this is set then Kannel do outgoing HTTP requests using this interface.
map-urlURL-pair The pair is separated with space. Adds a single mapping for the left side URL to the given destination. If you append an asterisk `*' to the left side URL, its prefix Is matched against the incoming URL. Whenever the prefix matches, the URL will be replaced completely by the right side. In addition, if if you append an asterisk to the right side URL, the part of the incoming URL coming after the prefix, will be appended to the right side URL. Thus, for a line: map-url = "http://source/* http://destination/*" and an incoming URL of "http://source/some/path", the result will be "http://destination/some/path"
map-url-maxnumber If you need more than one mapping, set this to the highest number mapping you need. The default gives you 10 mappings, numbered from 0 to 9. Default: 9
map-url-0URL-pair Adds a mapping for the left side URL to the given destination URL. Repeat these lines, with 0 replaced by a number up to map-url-max, if you need several mappings.
device-homeURL Adds a mapping for the URL DEVICE:home (as sent by Phone.com browsers) to the given destination URL. There is no default mapping. NOTE: the mapping is added with both asterisks, as described above for the "map-url" setting. Thus, the above example line is equivalent to writing map-url = "DEVICE:home* http://some.where/*"
log-filefilename As with bearerbox 'core' group.
log-levelnumber 0..5
syslog-levelnumber Messages of this log level or higher will also be sent to syslog, the UNIX system log daemon. The wapbox logs under the 'daemon' category. The default is not to use syslog, and you can set that explicitly by setting syslog-level to 'none'.
access-logfilename A file containing all requested URLs from clients while wapbox operation, including client IP, HTTP server User-Agent string, HTTP reponse code, size of reply.
access-log-cleanboolean Indicates if access-log will contain standard 'markers', which means the 'Log begins', 'Log ends' markers and the prefixed timestamp. This config directive should be set to 'true' if a custom logging format is desired without a prefixed default timestamp.
access-log-timestring Determine which timezone we use for access logging. Use 'gmt' for GMT time, anything else will use local time. Default is local time.
smart-errorsbool If set wapbox will return a valid WML deck describing the error that occurred while processing an WSP request. This may be used to have a smarter gateway and let the user know what happened actually.
wml-strictbool If set wapbox will use a strict policy in XML parsing the WML deck. If not set it will be more relaxing and let the XML parser recover from parsing errors. This has mainly impacts in how smart the WML deck and it's character set encoding can be addopted, even while you used an encoding that does not fit the XML preamble. BEWARE: This may be a vulnerability in your wapbox for large bogus WML input. Therefore this defaults to 'yes', strict parsing. is assimed.

Running WAP gateway

WAP Gateway is ran as explained in previous chapter.


Checking whether the WAP gateway is alive

You can check whether the WAP gateway (both the bearerbox and the wapbox) is alive by fetching the URL kannel:alive.


Chapter 5. Setting up MSISDN provisioning for WAP gateway

This chapter tells you how to set Kannel up to deliver the MSISDN number of the WAP device using the WAP gateway.

Mostly this feature is interested because the WAP protocol stack itself does not provide such a protocol layer bridging of information. In case you want to know which unique MSISDN is used by the WAP device your HTTP application is currently interacting, then you can pick this information from a RADIUS server that is used by a NAS (network access server) for authentication and accounting purposes.

Kannel provides a RADIUS accounting proxy thread inside wapbox which holds a mapping table for the dynamically assigned (DHCP) IP addresses of the WAP clients and their MSISDN numbers provided to the NAS device.

Beware that you HAVE TO to be in control of the NAS to configure it to use Kannel's wapbox as RADIUS accounting server. You can not use MSISDN provisioning via Kannel's RADIUS accounting proxy if you can not forward the accounting packets to Kannel's accounting proxy thread. So obviously this feature is for operators and people who have dedicated dial-in servers (NAS).


RADIUS accounting proxy configuration

To set up the RADIUS accounting proxy thread inside Kannel you have to define a 'radius-acct' group.


RADIUS-Acct configuration

The simplest working 'radius-acct' group looks like this:

group = radius-acct
our-port = 1646
secret-nas = radius
This example does not forward any accounting packets to a remote RADIUS server. There is, however, multiple optional variables for the 'radius-acct' group.

Table 5-1. RADIUS-Acct Group Variables

VariableValueDescription
group (m)radius-acct This is mandatory variable if you want to have Kannel's RADIUS accounting proxy thread to be active inside wapbox.
secret-nas (m)string Specifies the shared secret between NAS and our RADIUS accounting proxy.
secret-radiusstring Specifies the shared secret between our RADIUS accounting proxy and the remote RADIUS server itself in case we are forwarding packets.
our-hostIP address Specifies the local interface where our-port value will bind to. (defaults to 0.0.0.0)
remote-hostFQDN or IP address Specifies the remote RADIUS server to which we forward the accounting packets. If none is given, then no forwarding of accounting packets is performed.
our-portnumber Specifies the port to which our RADIUS accounting proxy thread will listen to. (defaults according to RFC2866 to 1813)
remote-portnumber Specifies the port to which our RADIUS accounting proxy thread will forward any packets to the remote-host. (defaults according to RFC2866 to 1813)
remote-timeoutnumber Specifies the timeout value in milliseconds for waiting on a response from the remote RADIUS server. (defaults to 40 msecs.)
nas-portsnumber Specifies how many possible clients can connect simultaneously to the NAS. This value is used to initialize the mapping hash table. If does not require to be exact, because the table grows automatically if required. (defaults to 30)
unified-prefixprefix-list String to unify provided phone numbers from NAS. Format is that first comes the unified prefix, then all prefixes which are replaced by the unified prefix, separated with comma (','). For example, for Finland an unified-prefix "+358,00358,0;+,00" should do the trick. If there are several unified prefixes, separate their rules with semicolon (';'), like "+35850,050;+35840,040".

Using the MSISDN provisioning on HTTP server side

Kannel's wapbox will include a specific HTTP header in the HTTP request issued to the URL provided by the WAP client. That HTTP header is X-WAP-Network-Client-MSISDN. It will carry as value the MSISDN of the WAP client if the RADIUS accounting proxy has received a valid accounting packet from the NAS that provided the client IP.


Chapter 6. Setting up a SMS Gateway

This chapter is a more detailed guide on how to set up Kannel as an SMS gateway.


Required components

To set up an SMS gateway, you need, in addition to a machine running Kannel, access to (an operator's) SMS center, or possibly to multiple ones. The list of supported SMS centers and their configuration variables is below.

If you do not have such access, you can still use Kannel as an SMS gateway via phone-as-SMSC feature, by using a GSM phone as a virtual SMS center.

In addition to an SMS center (real or virtual), you need some server to handle any SMS requests received. This server then has simple or more complex cgi-bins, programs or scripts to serve HTTP requests generated by Kannel in response to received SMS messages. These services can also initiate SMS push via Kannel smsbox HTTP sendsms interface.


SMS gateway configuration

To set up a SMS Kannel, you have to edit the 'core' group in the configuration file, and define an 'smsbox' group plus one or more 'sms-service' groups, plus possibly one or more 'sendsms-user' groups.

For the 'core' group, you must set the following variable: smsbox-port. In addition, you may be interested to set unified-prefix, white-list and/or black-list variables. See above for details of these variables.

A sample configuration file smskannel.conf is supplied with the standard distribution. You may want to take a look at that when setting up an SMS Kannel.


SMS centers

To set up the SMS center at Kannel, you have to add a 'smsc' group into configuration file. This group must include all the data needed to connect that SMS center. You may also want to define an ID (identification) name for the SMSC, for logging and routing purposes.

SMSC ID is an abstract name for the connection. It can be anything you like, but you should avoid any special characters. You do not need to use ID, but rely on SMS center IP address and other information. However, if you use the ID, you do not need to re-define sms-services nor routing systems if the IP of the SMS Center is changed, for example.

Common 'smsc' group variables are defined in the following table. The first two (group and smsc) are mandatory, but rest can be used if needed.

Table 6-1. SMSC Group Variables

VariableValueDescription
group (m)smsc This is a mandatory variable
smsc (m)string Identifies the SMS center type. See below for a complete list.
smsc-idstring An optional name or id for the smsc. Any string is acceptable, but semicolon ';' may cause problems, so avoid it and any other special non-alphabet characters. This 'id' is written into log files and can be used to route SMS messages, and to specify the used SMS-service. Several SMSCs can have the same id. The name is case-insensitive. Note that if SMS Center connection has an assigned SMSC ID, it does NOT automatically mean that messages with identical SMSC ID are routed to it; instead configuration variables denied-smsc-id, allowed-smsc-id and preferred-smsc-id is used for that. If you want to use Delivery Reports, you must define this.
throughputnumber (messages/sec) If SMSC requires that Kannel limits the number of messages per second, use this variable. This is considered as active throttling. (optional)
denied-smsc-idid-list SMS messages with SMSC ID equal to any of the IDs in this list are never routed to this SMSC. Multiple entries are separated with semicolons (';')
allowed-smsc-idid-list This list is opposite to previous: only SMS messages with SMSC ID in this list are ever routed to this SMSC. Multiple entries are separated with semicolons (';')
preferred-smsc-idid-list SMS messages with SMSC ID from this list are sent to this SMSC instead than to SMSC without that ID as preferred. Multiple entries are separated with semicolons (';')
allowed-prefixprefix-list A list of phone number prefixes which are accepted to be sent through this SMSC. Multiple entries are separated with semicolon (';'). For example, "040;050" prevents sending of any SMS message with prefix of 040 or 050 through this SMSC. If denied-prefix is unset, only these numbers are allowed. If set, number are allowed if present in allowed or not in denied list.
denied-prefixprefix-list A list of phone number prefixes which are NOT accepted to be sent through this SMSC.
preferred-prefixprefix-list As denied-prefix, but SMS messages with receiver starting with any of these prefixes are preferably sent through this SMSC. In a case of multiple preferences, one is selected at random (also if there are preferences, SMSC is selected randomly)
unified-prefixprefix-list String to unify received phone numbers, for SMSC routing and to ensure that SMS centers can handle them properly. This is applied to 'sender' number when receiving SMS messages from SMS Center and for 'receiver' number when receiving messages from smsbox (either sendsms message or reply to original message). Format is that first comes the unified prefix, then all prefixes which are replaced by the unified prefix, separated with comma (','). For example, for Finland an unified-prefix "+358,00358,0;+,00" should do the trick. If there are several unified prefixes, separate their rules with semicolon (';'), like "+35850,050;+35840,040". Note that prefix routing is next to useless now that there are SMSC ID entries. To remove prefixes, use like "-,+35850,050;-,+35840,040".
alt-charsetnumber As some SMS Centers do not follow the standards in character coding, an alt-charset character conversion is presented. This directive acts different for specific SMSC types. Please see your SMSC module type you want to use for more details.
our-hosthostname Optional hostname or IP address in which to bind the connection in our end. TCP/IP connection only.
log-filefilename A file in which to write a log of the given smsc output. Hence this allows to log smsc specific entries to a separate file.
log-levelnumber 0..5 Minimum level of log-file events logged. 0 is for 'debug', 1 'info', 2 'warning, 3 'error' and 4 'panic' (see Command Line Options)
reconnect-delaynumber Number of seconds to wait between single re-connection attempts. Hence all SMSC modules should use this value for their re-connect behavior. (Defaults to '10' seconds).
rerouteboolean If set for a smsc group, all inbound messages coming from this smsc connection are passed internally to the outbound routing functions. Hence this messages is not delivered to any connected box for processing. It is passed to the bearerbox routing as if it would have originated from an externally connected smsbox. (Defaults to 'no').
reroute-smsc-idstring Similar to 'reroute'. Defines the explicit smsc-id the MO message should be passed to for MT traffic. Hence all messages coming from the the configuration group smsc are passed to the outbound queue of the specified smsc-id. This allows direct proxying of messages between 2 smsc connections without injecting them to the general routing procedure in bearerbox.
reroute-receiverstring Similar to 'reroute'. Defines the explicit smsc-id routes for specific receiver numbers of messages that are coming from this smsc connection. Format is that first comes the smsc-id to route the message to, then all receiver numbers that should be routed, separated with comma (','). For example, route receivers 111 and 222 to smsc-id A and 333 and 444 to smsc-id B would look like: "A,111,222; B,333,444".
reroute-dlrboolean Indicate whether DLR's should be re-routed too, if one of above reroute rules are enabled. Please note, that SMSC-Module should support DLR sending. At time of writing none of SMSC-Module supports DLR sending.
allowed-smsc-id-regexPOSIX regular expression SMS messages with SMSC ID equal to any of the IDs in this set of SMSC IDs are always routed to this SMSC. See section on regular expressions for details.
denied-smsc-id-regexPOSIX regular expression SMS messages with SMSC ID equal to any of the IDs in this set of SMSC IDs are never routed to this SMSC. See section on regular expressions for details.
preferred-smsc-id-regexPOSIX regular expression SMS messages with SMSC ID in this set of SMSC IDs are sent to this SMSC as preferred. See section on regular expressions for details.
allowed-prefix-regexPOSIX regular expression A set of phone number prefixes which are accepted to be sent through this SMSC. See section on regular expressions for details.
denied-prefix-regexPOSIX regular expression A set of phone number prefixes which may not be sent through this SMSC. See section on regular expressions for details.
preferred-prefix-regexPOSIX regular expression As denied-prefix-regex, but SMS messages with receiver matching any of these prefixes are preferably sent through this SMSC. In a case of multiple preferences, one is selected at random. See section on regular expressions for details.

In addition to these common variables there are several variables used by certain SMS center connections. Each currently supported SMS center type is explained below, with configuration group for each. Note that many of them use variables with same name, but most also have some specific variables.

NOTE: SMS center configuration variables are a bit incomplete, and will be updated as soon as people responsible for the protocols are contacted. Meanwhile, please have patience.


Nokia CIMD 1.37 and 2.0

Support for CIMD 1.37 is quite old and will be removed in a future version of Kannel. Please let us know if you still need it.

group = smsc
smsc = cimd
host = 100.101.102.103
port = 600
smsc-username = foo
smsc-password = bar

The driver for CIMD2 is a "receiving SME" and expects the SMSC to be configured for that. It also expects the SMSC to automatically send stored messages as soon as Kannel logs in (this is the normal configuration).

group = smsc
smsc = cimd2
host = 100.101.102.103
port = 600
smsc-username = foo
smsc-password = bar
keepalive = 5 
my-number = "12345"

VariableValueDescription
host (m)hostname Machine that runs the SMSC. As IP (100.100.100.100) or hostname (their.machine.here)
port (m)port-number Port number in the smsc host machine
smsc-username (m)string Username in the SMSC machine/connection account
smsc-password (m)string Password in the SMSC machine needed to contact SMSC
keepalivenumber SMSC connection will not be left idle for longer than this many seconds. The right value to use depends on how eager the SMSC is to close idle connections. If you see many unexplained reconnects, try lowering this value. Set it to 0 to disable this feature.
no-dlrboolean Optional. If defined, status delivery report requests (DLR) won't be requested at all. Some CIMD2 SMSC have prohibited these reports so if you are getting error like "Incorrect status report request parameter usage", this option is for you. Defaults to "false".
my-numberstring The number that the SMSC will add in front of the sender number of all messages sent from Kannel. If Kannel is asked to send a message, it will remove this prefix from the sender number so that the SMSC will add it again. If the prefix was not present, Kannel will log a warning and will not send the sender number. If my-number is not set, or is set to "never", then Kannel will not send the sender number to the SMSC at all. If you want Kannel to pass all sender numbers to the SMSC unchanged, then just set sender-prefix to the empty string "".
our-portport-number Optional port number in which to bind the connection in our end.


CMG UCP/EMI 4.0 and 3.5

Warning

See Appendix A for changes.

Kannel supports two types of connections with CMG SMS centers: direct TCP/IP connections ( emi) and ISDN/modem (X.25) connection (emi_x25).

Note: emi_x25 is an old implementation and supports less features than it's IP counterpart. If you still need this module, please tell us to devel@kannel.org so we can fix it.

Sample configurations for these are:

group = smsc
smsc = emi
host = 103.102.101.100
port = 6000
smsc-username = foo
smsc-password = bar
keepalive = 55
our-port = 600 (optional bind in our end)
receive-port = 700 (the port in which the SMSC will contact)
idle-timeout = 30

group = smsc
smsc = emi_x25
phone = ...
device = /dev/tty0
smsc-username = foo
smsc-password = bar

VariableValueDescription
host (c)hostname Machine that runs SMSC. As IP (100.100.100.100) or hostname (their.machine.here)
port (c)port-number Port number in the SMSC host machine
alt-hosthostname Optional alternate Machine that runs SMSC. As IP (100.100.100.100) or hostname (their.machine.here) (If undef but exists alt-port, emi2 would try host:alt-port)
alt-portport-number Optional alternate Port number in the SMSC host machine (If undef but exists alt-host, emi2 would try alt-host:port)
smsc-usernamestring Username in the SMSC machine/connection account
smsc-passwordstring Password in the SMSC machine needed to contact SMSC
device (c)device-name The device the modem is connected to, like /dev/ttyS0. ISDN connection only.
phone (c)string Phone number to dial to, when connecting over a modem to an SMS center.
our-portport-number Optional port number in which to bind the connection in our end. TCP/IP connection only.
receive-portport-number Optional port number we listen to and to which the SMS center connects when it has messages to send. Required if SMS center needs one connection to send and other to receive. TCP/IP connection only.
appnamestring Name of a "Send only" service. Defaults to send. All outgoing messages are routed through this service.
connect-allow-ipIP-list If set, only connections from these IP addresses are accepted to receive-port. TCP/IP connection only.
idle-timeoutnumber (seconds) If this option is set to a value larger than 0, then the connection will be closed after the configured amount of seconds without activity. This option interacts with the keepalive configuration option. If keepalive is smaller than idle-timeout, then the connection will never be idle and those this option has no effect. If keepalive is larger than idle-timeout, than keepalive reopens the connection. This allows one to poll for pending mobile originated Short Messages at the SMSC.
keepalivenumber (seconds) A keepalive command will be sent to the SMSC connection this many seconds after the last message. The right value to use depends on how eager the SMSC is to close idle connections. 50 seconds is a good guess. If you see many unexplained reconnects, try lowering this value. Set it to 0 to disable this feature. Requires username or my-number to be set.
wait-acknumber (seconds) A message is resent if the acknowledge from SMSC takes more than this time. Defaults to 60 seconds.
wait-ack-expirenumber Defines what kind of action should be taken if the the ack of a message expires. The options for this value are: 0x00 - disconnect/reconnect, (default) 0x01 - as is now, re-queue, but this could potentially result in the msg arriving twice 0x02 - just carry on waiting (given that the wait-ack should never expire this is the mst accurate)
flow-controlnumber This SMSC can support two types of flow control. The first type of flow control is a stop-and-wait protocol, when this parameter equals to '1'. During the handling of commands, no other commands shall be sent before the a response is received. Any command that is sent before the reception of the response will be discarded. The second type of flow control is windowing, when this parameter is unset or equals '0'. In this case a maximum of n commands can be sent before a response is received.
windownumber (messages) When using flow-control=0, emi works in windowed flow control mode. This variable defines the size of the window used to send messages. (optional, defaults to the maximum - 100)
my-numbernumber If the large account number is different from the short number, assign it with this variable. For example, if short number is 12345 and large account is 0100100100101234 (IP+port), set my-number to 12345 and every message received will have that receiver. In addition, if you are bound to the SMSC without an explicit login, use this configuration directive to enable keep-alive (OP/31) operations.
alt-charsetnumber Defines which character conversion kludge may be used for this specific link. Currently implemented alternative charsets are defined in "alt_charsets.h" and new ones can be added.
notification-pid4 num char. Notification PID value. See below for a complete list and other notes. Example: 0539 [a]
notification-addrstring (max 16) Notification Address. Example: 0100110120131234. [b]
Notes:
a. If you set notification-pid, you should also set notification-addr.
b. If you set notification-addr, you should also set notification-pid.

You should use notification-pid and notification-addr if you need to inform your exact "address" to your smsc. For example, if you have a Multiple-Address (MA) account with several connections to the same short number, you may need to tell your smsc to send delivery reports to the exact instance that sent the message. This is required because if you send a message with instance 1, your instance 2 wouldn't know about it, unless you use a shared DB store for delivery reports.

Notification PID ValueDescription
0100Mobile Station
0122Fax Group 3
0131X.400
0138Menu over PSTN
0139PC appl. over PSTN (E.164)
0339PC appl. over X.25 (X.121)
0439PC appl. over ISDN (E.164)
0539PC appl. over TCP/IP


SMPP 3.4

This implements Short Message Peer to Peer (SMPP) Protocol 3.4 in a manner that should also be compatible with 3.3. Sample configuration:

group = smsc
smsc = smpp
host = 123.123.123.123
port = 600
receive-port = 700 
smsc-username = "STT"
smsc-password = foo
system-type = "VMA"
address-range = ""

VariableValueDescription
host (m)hostname Machine that runs SMSC. As IP (100.100.100.100) or hostname (their.machine.here)
port (m)port-number The port number for the TRANSMITTER connection to the SMSC. May be the same as receive-port. Use value 0 to disable this I/O thread.
transceiver-modebool Attempt to use a TRANSCEIVER mode connection to the SM-SC. It uses the standard transmit 'port', there is no need to set 'receive-port'. This is a SMPP 3.4 only feature and will not work on an earlier SM-SC. This will try a bind_transceiver only and will not attempt to fall back to doing transmit and receive on the same connection.
receive-portport-number The port number for the RECEIVER connection to the SMSC. May be the same as port. Use value 0 to disable this I/O thread.
smsc-username (m)string The 'username' of the Messaging Entity connecting to the SM-SC. If the SM-SC operator reports that the "TELEPATH SYSTEM MANAGER TERMINAL" view "Control.Apps.View" value "Name:" is "SMPP_ZAPVMA_T" for the transmitter and "SMPP_ZAPVMA_R" for the receiver the smsc-username value is accordingly "SMPP_ZAP". Note that this used to be called system-id (the name in SMPP documentation) and has been changed to smsc-username to make all Kannel SMS center drivers use the same name.
smsc-password (m)string The password matching the "smsc-username" your teleoperator provided you with.
system-type (m)string Usually you can get away with "VMA" which stands for Voice Mail Activation.
service-typestring Optional; if specified, sets the service type for the SMSC. If unset, the default service type is used. This may be used to influence SMS routing (for example). The SMSC operator may also refer to this as the "profile ID". The maximum length of the service type is 6, according to the SMPP specification v3.4.
interface-versionnumber Change the "interface version" parameter sent from Kannel to a value other then 0x34 (for SMPP v3.4). the value entered here should be the hexadecimal representation of the interface version parameter. for example, the default (if not set) is "34" which stands for 0x34. for SMPP v3.3 set to "33".
address-range (m)string According to the SMPP 3.4 spec this is supposed to affect which MS's can send messages to this account. Doesn't seem to work, though.
my-numbernumber Optional smsc short number. Should be set if smsc sends a different one.
enquire-link-intervalnumber Optional the time lapse allowed between operations after which an SMPP entity should interrogate whether it's peer still has an active session. The default is 30 seconds.
max-pending-submitsnumber Optional the maximum number of outstanding (i.e. acknowledged) SMPP operations between an ESME and SMSC. This number is not specified explicitly in the SMPP Protocol Specification and will be governed by the SMPP implementation on the SMSC. As a guideline it is recommended that no more than 10 (default) SMPP messages are outstanding at any time.
reconnect-delaynumber Optional the time between attempts to connect an ESME to an SMSC having failed to connect initiating or during an SMPP session. The default is 10 seconds.
source-addr-tonnumber Optional, source address TON setting for the link. (Defaults to 0).
source-addr-npinumber Optional, source address NPI setting for the link. (Defaults to 1).
source-addr-autodetectboolean Optional, if defined tries to scan the source address and set TON and NPI settings accordingly. If you don't want to autodetect the source address, turn this off, by setting it to no. (Defaults to yes).
dest-addr-tonnumber Optional, destination address TON setting for the link. (Defaults to 0).
dest-addr-npinumber Optional, destination address NPI setting for the link. (Defaults to 1).
bind-addr-tonnumber Optional, bind address TON setting for the link. (Defaults to 0).
bind-addr-npinumber Optional, bind address NPI setting for the link. (Defaults t