Kannel 1.1.5 User's Guide

Open Source WAP and SMS gateway

Lars Wirzenius

Kalle Marjola


Table of Contents
1. Introduction
Overview of WAP
Overview of SMS
Features
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
3. Using the gateway
Configuring the gateway
Configuration file syntax
Core configuration
Running Kannel
Starting the gateway
Command line options
Kannel statuses
HTTP administration
4. Setting up a WAP gateway
WAP gateway configuration
Wapbox configuration
Running WAP gateway
Checking whether the WAP gateway is alive
5. Setting up a SMS Gateway
Required components
SMS gateway configuration
SMS centers
Smsbox configuration
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
6. Setting up a SMS&WAP gateway
SMS&WAP gateway configuration
Running SMS&WAP gateway
7. Getting help and reporting bugs
A. Using the fake WAP sender
B. Using the fake SMS center
Setting up fakesmsc
Compiling fakesmsc
Configuring Kannel
Running Kannel with fakesmsc connections
Starting fake SMS center
C. Setting up a dial-up line
Analog modem
ISDN terminal
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. SMSC Group Variables
5-2. SMSC driver features
5-3. Smsbox Group Variables
5-4. SMS-Service Group Variables
5-5. Parameters (Escape Codes)
5-6. SendSMS-User Group Variables
5-7. OTA Config Group Variables
5-8. SMS Push (send-sms) CGI Variables
5-9. OTA CGI Variables
B-1. Fakesmsc command line options
List of Figures
1-1. Logical position of WAP gateway 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.

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.

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 bytecode format.

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 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 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.

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.


Requirements

Kannel is being developed on Linux systems (Red Hat 6.1 and Debian potato), 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. Kannel requires the following software environment:

Hardware requirements are fluffier. We haven't benchmarked Kannel yet, so there are no hard numbers, but a reasonably fast PC workstation (400 MHz Pentium II, 128 MB RAM) should serve several concurrent users or tens of SMS messages per second without problems.


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.


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.

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.

You need the following tools to compile Kannel:

  • C compiler and libraries for ANSI C, with normal Unix extensions such as BSD sockets.

  • 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 stylesheets, jade, jadetex, etc; see README.docbook 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.


Compiling the gateway

If you are using Kannel on a supported platform, or one that is similar enough to one, compiling Kannel is trivial. After you have unpacked the source package of your choosing, 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 7 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 debug.

  • --enable-docs Build documentation, b.e., converting the User Guide and the Architecture Guide from the DocBook markup language to PostScript and HTML.

  • --disable-docs Don't build documentation.

  • --enable-debug Enable non-reentrant development time debugging of WMLScript compiler.

  • --enable-localtime Write log file time stamps in local time, not GMT.

  • --disable-assertions Turn off runtime assertion checking. This makes Kannel faster, but gives less information if it crashes.

  • --with-malloc=type Select memory allocation module to use: type is native, checking (the default), or slow. For production use you probably want native. The slow module is more thorough than checking, but much slower.

  • --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.

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.)


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. Log in as root:

su -

3. Install the RPM package:

rpm -ivh kannel-VERSION.i386.rpm

Upgrading Kannel

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

2. Log in as root

3. Upgrade the RPM package:

rpm -Uvh kannel-VERSION.i386.rpm

Removing Kannel

1. Log in as root:

2. 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 the same directory there is an example file called smskannel.conf. It has 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 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/share/doc/kannel-VERSION/ or /usr/doc/kannel-VERSION/ depending on if you used the RedHat 7.x or 6.x 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.


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 combined gateway. These chapters explain the configuration and other aspects of gateway of that type.

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.
4    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'.


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 www server, just invent any port, but it must be over 1023 unless you are running Kannel as a root process (not recommended)
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 wildcard 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.
wapbox-port (c)port-number Like smsbox-port, but for wapbox-connections. If not set, Kannel cannot handle WAP traffic
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 wildcard 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 logfile 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.
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
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 from 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. Does not support sendsms messages yet!
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-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-certkey-filessl-certkey-file A PEM encoded SSL certificate and private key file to be used with SSL connections.

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.


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.


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 configuration

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
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'.

Chapter 5. Setting up a SMS Gateway

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


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 5-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.
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 (';')
denied-prefixprefix-list A list of phone number prefixes which are NOT 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
preferred-prefixprefix-list As denied-prefix, but SMS messages with receiver starting with any of these prefixes is 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)
alt-charsetnumber As some SMS Centers do not follow the standards in character coding, an alt-charset kludge is presented. Currently implemented alternative charsets are defined in "alt_charsets.h" and new ones can be added to appropriate smsc-code.

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 
sender-prefix = "12345"

CMG UCP/EMI 3.5

Kannel supports two types of connections with CMG SMS centers: direct TCP/IP connections (emi_ip or emi2) and ISDN/modem (X.25 over D channel ISDN is called X.31) connection (emi). emi2 is a new implementation of the EMI protocol that supports more features and should work more reliably than the old one. It is the recommended one to use with TCP/IP connections. Sample configurations for these are:

group = smsc
smsc = emi2
#smsc = emi_ip to use the old implementation
host = 103.102.101.100
port = 600
smsc-username = foo
smsc-password = bar
our-port = 600 (optional bind in our end)
receive-port = 700 (the port in which the SMSC will contact)

group = smsc
smsc = emi
host = 100.102.100.102
phone = ...
device = /dev/tty0
smsc-username = foo
smsc-password = bar

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 = ""

Feature checklist

Not all of Kannel's SMSC drivers support the same set of features. This is because they were written at different times, and new features are often only added to drivers that the feature author can test.

The table in this section is an attempt to show exactly what features to expect from a driver, and to help identify areas where drivers need to be updated. Currently most of the entries are marked as "not tested" because the table is still new.

Some of the items are not really features, but rather the absence of specific bugs that seem to show up often.


Smsbox configuration

You must define an 'smsbox' group into the configuration file to be able to use SMS Kannel. The simplest working 'smsbox' group looks like this:

group = smsbox
bearerbox-host = localhost
...but you would most probably want to define 'sendsms-port' to be able to use SMS push.

A typical 'smsbox' group could be something like this:

group = smsbox
bearerbox-host = localhost
sendsms-port = 13131
sendsms-chars = "0123456789 "
global-sender = 123456
access-log = "kannel.access"
log-file = "smsbox.log"
log-level = 0


SMS-service configurations

Now that you have an SMS center connection to send and receive SMS messages you need to define services for incoming messages. This is done via 'sms-service' configuration groups.

These groups define SMS services in the smsbox, so they are only used by the smsbox. Each service is recognized from the first word in an SMS message and by the number of arguments accepted by the service configuration (unless catch-all configuration variable is used). By adding a username and password in the URL in the following manner "http://luser:password@host.domain:port/path?query" we can perform HTTP Basic authentication.

The simplest service group looks like this:

group = sms-service
keyword = www
get-url = "http://%S"
This service grabs any SMS with two words and 'www' as the first word, and then does an HTTP request to an URL which is taken from the rest of the message. Any result is sent back to the phone (or requester), but is truncated to the 160 characters that will fit into an SMS message, naturally.

Service group default has a special meaning: if the incoming message is not routed to any other service, default 'sms-service' group is used. You should always define default service.

Table 5-4. SMS-Service Group Variables

VariableValueDescription
group (m)sms-service This is a mandatory variable
keyword (m)word Services are identified by the first word in the SMS Each `%s' in the URL corresponds to one word in the SMS message. Words are separated with spaces. A keyword is matched only if the number of words in the SMS message is the same as the number of `%s' fields in the URL. This allows you to configure the gateway to use different URLs for the same keyword depending on the number of words the SMS message contains.
aliasesword-list If the service has aliases, they are listed as a list with each entry separated with a semicolon (';')
get-url (c)URL Requested URL. The url can include a list of parameters, which are parsed before the url is fetched. See below for these parameters. Also works with plain 'url'
post-url (c)URL Requested URL. As above, but request is done as POST, not GET. Always matches the keyword, regardless of pattern matching. See notes on POST otherwhere.
file (c)filename File read from a local disc. Use this variable only if no url is set. All escape codes (parameters) in url are supported in filename. The last character of the file (usually linefeed) is removed.
text (c)string Predefined text answer. Only if there is neither url nor file set. Escape codes (parameters) are usable here, too.
accepted-smscid-list Accept ONLY SMS messages arriving from SMSC with matching ID. Separate multiple entries with ';'. For example, if accepted-smsc is "RL;SON", accept messages which originate from SMSC with ID set as 'RL' or 'SON'
catch-allbool Catch keyword regardless of '%s' parameters in pattern.
send-senderbool Used only with POST. If set to true, number of the handset is set, otherwise not.
strip-keywordbool Used only with POST. Remove matched keyword from message text before sending it onward.
faked-senderphone-number This number is set as sender. Most SMS centers ignore this, and use their fixed number instead. This option overrides all other sender setting methods.
max-messagesnumber If the message to be sent is longer than maximum length of an SMS it will be split into several parts. max-messages lets you specify a maximum number of individual SMS messages that can be used. If max-messages is set to 0, no reply is sent, except for error messages.
accept-x-kannel-headersbool Request reply can include special X-Kannel headers but these are only accepted if this variable is set to true. See Extended headers.
assume-plain-textbool If client does not set Content-Type for reply, it is normally application/octet-stream which is then handled as data in kannel. This can be forced to be plain/text to allow backward compatibility, when data was not expected.
concatenationbool Long messages can be sent as independent SMS messages with concatenation = false or as concatenated messages with concatenation = true. Concatenated messages are reassembled into one long message by the receiving device.
split-charsstring Allowed characters to split the message into several messages. So, with "#!" the message is split from last '#' or '!', which is included in the previous part.
split-suffixstring If the message is split into several ones, this string is appended to each message except the last one.
omit-emptybool Normally, Kannel sends a warning to the user if there was an empty reply from the service provider. If omit-empty is set to 'true', Kannel will send nothing at all in such a case.
headerstring If specified, this string is automatically added to each SMS sent with this service. If the message is split, it is added to each part.
footerstring As header, but not inserted into head but appended to end.
prefixstring Stuff in answer that is cut away, only things between prefix and suffix is left. Not case sensitive. Matches the first prefix and then the first suffix. These are only used for url type services, and only if both are specified.
suffixstring

Some sample 'sms-service' groups:

group = sms-service
keyword = nop
text = "You asked nothing and I did it!"
catch-all = true

group = sms-service
keyword = complex
get-url = "http://my.applet.machine/Servlet/kludge2?sender=%p&text=%r"
accept-x-kannel-headers = true
max-messages = 3
concatenation = true

group = sms-service
keyword = default
text = "No action specified"


SendSMS-user configurations

To enable an SMS push, you must set sendsms-port into the 'smsbox' group and define one or more 'sendsms-user' groups. Each of these groups define one account, which can be used for the SMS push, via HTTP interface (see below)

Some sample 'sendsms-user' groups:

group = sendsms-user
username = simple
password = elpmis

group = sendsms-user
username = complex
password = 76ftY
user-deny-ip = "*.*.*.*"
user-allow-ip = "123.234.123.234"
max-messages = 3
concatenation = true
forced-smsc = SOL
The second one is very limited and only allows a user from IP "123.234.123.234". On the other hand, the user can send a longer message, up to 3 SMSes long, which is sent as concatenated SMS.


Over-The-Air configurations

To enable Over-The-Air configuration of phones or other client devices that support the protocol you need to configure a otaconfig group and a sendsms-user.

If you want to send multiple OTA configurations through the smsbox you will have to declare a ota-id string to the different otaconfig groups.

A sample 'otaconfig' group:

group = otaconfig
location = http://wap.company.com
service = "Our company's WAP site"
ipaddress = 10.11.12.13
phonenumber = 013456789
bearer = data
calltype = analog
connection = cont
pppsecurity = off
authentication = normal
login = wapusr
secret = thepasswd
And a 'sendsms-user' to use with it. With concatenation enabled:
group = sendsms-user
username = otauser
password = foo
max-messages = 2
concatenation = 1


Setting up more complex services

The basic service system is very limited - it can only answer to original requester and it cannot send UDH data, for example. This chapter explains some more sophisticated and complex SMS service setups.


Running SMS gateway

Using the HTTP interface to send SMS messages

After you have configured Kannel to allow the sendsms service, you can send SMS messages via HTTP, e.g., using a WWW browser. The URL looks something like this:

http://smsbox.host.name:13013/cgi-bin/sendsms?username=foo&password=bar&to=0123456&text=Hello+world
Thus, technically, you make an HTTP GET request. This means that all the information is stuffed into the URL. If you want to use this often via a browser, you probably want to make an HTML form for this.


Chapter 6. Setting up a SMS&WAP gateway

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


Chapter 7. Getting help and reporting bugs

This chapter explains where to find help with problems related to the gateway, and the preferred procedure for reporting bugs and sending corrections to them.

The Kannel development mailing list is devel@kannel.org. To subscribe, send mail to devel-subscribe@kannel.org. This is currently the best location for asking help and reporting bugs. Please include configuration file and version number.


Appendix A. Using the fake WAP sender

This appendix explains how to use the fake WAP sender to test the gateway.


Appendix B. Using the fake SMS center

Fakesmsc is a simple testing tool to test out Kannel and its SMS services. It cannot be used to send messages to mobile terminals, it is just a simulated SMS center with no connection to real terminals.


Running Kannel with fakesmsc connections

After configuring Kannel, you can start testing it. The bearerbox will listen for fakesmsc client connections to the port(s) specified in the configuration file.


Starting fake SMS center

Each fakesmsc is started from command line, with all sent messages after command name. If any options are used (see below), they are put between the command and the messages. The usage is as follows:

test/fakesmsc [options] <message1> [message2 ...]

Options and messages are explained below, but as a quick example, a typical startup can go like this:

test/fakesmsc -i 0.1 -m 100 "100 200 text nop" "100 300 text echo this"

This tells fakesmsc to connect to bearerbox at localhost:10000 (default) and send a hundred messages with an interval of 0.1 seconds. Each message is from number 100, and is either to number 200 with message 'nop' or to 300 with message 'echo this'.

Messages received from bearerbox are shown in the same format (described below).


Appendix C. Setting up a dial-up line

This appendix explains how to set up a dial-up line in Linux for use with the Kannel WAP gateway. In order for it to work you need a Linux kernel with PPP capabilities. Most distributions provides PPP kernel support by default. For more information how to compile PPP support into the kernel please read the "Linux Kernel HOWTO" at http://www.linuxdoc.org/.


Analog modem

This section explains how to set up a dial-up line with an analog modem.

Download and install the mgetty package.

	rpm -ivh mgetty-VERSION-rpm
	

To run mgetty as a daemon, add the following line to /etc/inittab.

Read man inittab for more detailed information. In this example we assume your modem is connected to the serial port ttyS0 (COM 1).

	S0:2345:respawn:/sbin/mgetty ttyS0 -x 6 -D /dev/ttyS0
	
	

We need to start the pppd automatically when mgetty receives an AutoPPP request. Add the next line to /etc/mgetty+sendfax/login.config

	/AutoPPP/ - - /usr/sbin/pppd file /etc/ppp/options.server
	
	

In /etc/mgetty+sendfax/mgetty.config you might need to change the connect speed between the computer and the modem. Note: this is not the connect speed between the WAP client and the server modem. If you are e.g. going to use a Nokia 7110 as the server side modem you need to change the speed to 19200. Usually you can just leave the speed to the default value (38400).

	speed 38400
	

Add the following lines to /etc/ppp/options.server

	refuse-chap
	require-pap
	lock
	modem
	crtscts
	passive
	192.168.1.10:192.168.1.20
	debug
	
	

In /etc/ppp/pap-secrets add the username and password for the ppp account. The IP address is the one assigned to the phone.

	wapuser * wappswd 192.168.0.20
	

Configure your phone (this example is for Nokia 7110)

	homepage http:/yourhost/hello.wml
	connection type continuous
	connection security off
	bearer data
	dial up number (your phone number)
	ip address (IP of host running bearerbox)
	auth type normal
	data call type analogue
	data call speed 9600
	username wapuser
	password wappswd