2012 f 3

Following on from my initial post this is a very short post to describe my network and telephony topology.

I’m in the very privileged class who own their own class-C network from way-back. The assholes at AUNIC keep on trying to steal it back by ever more draconian rules to make it impossible for me to keep my in-addr-arpa domain alive. Luckily I have survived so far but my design plan allows for transition to a NAT model if required.

At present I have an upstream SIP Trunk provider who runs Asterisk (Pthuewee!). I have some PSTN numbers that they rout to my Kamailio instance that I then distribute to my extensions. My extensions are registered to my Kamailio server. I also run rtpproxy so that external extensions can have a proxy IP address for media within the permitted range for my SIP trunk provider..

My internal numbering system has extensions in the 200 range. This works a lot better than 100 series which are continually probed by exploit bots.

I have entries in db_aliases that match PSTN numbers to specific 200 series extensions. In reverse I can translate internal extensions to PSTN numbers in the outgoing headers.

All works fine except when I want to do a call transfer between extensions. My upstream Asterisk provider doesn’t support REFER messages. Even worse it sends fake progress messages as though it does support them but actually does nothing. This is the main reason I have decided to set up a Kamailio/SEMS PBX where I can take control of the trunk system and also provide more functionality within my network and remote extensions.

Ultimately SEMS will (probably) replace rtpproxy and the upstream provider will have zero control of my PBX and DID/DDI numbers.


SEMS and KAMAILIO combo as a PBX – concept

2012 f 3

This is a record of how to make a workable PBX using SEMS and KAMAILIO on CENTOS 6.3. This procedure will be applicable to most OSs that can run CENTOS and KAMAILIO.

This is not a description of how to do it. It’s a log of my attempts to make it happen. The last post will be a recipe to follow.

First, what is a PBX AKA PABX AKA EPABX ?

Using Wikipedia we see that PBXs have the following list of capabilities

  •     Auto attendant
  •     Auto dialing
  •     Automatic call distributor
  •     Automated directory services (where callers can be routed to a given employee)
  •     Automatic ring back
  •     Call accounting
  •     Call blocking
  •     Call forwarding on busy or absence
  •     Call park
  •     Call pick-up
  •     Call transfer
  •     Call waiting
  •     Camp-on (?wtf?)
  •     Conference call
  •     Custom greetings
  •     Customised Abbreviated dialing (Speed Dialing)
  •     Busy Override
  •     Direct Inward Dialing
  •     Direct Inward System Access (DISA) (the ability to access internal features)
  •     Do not disturb (DND)
  •     Follow-me, also known as find-me: Determines the routing of incoming calls.
  •     Interactive voice response
  •     Music on hold
  •     Night service
  •     Public address voice paging
  •     Shared message boxes (where a department can have a shared voicemail box)
  •     Voice mail
  •     Voice message broadcasting
  •     Welcome Message

Strewth! That’s a lot!. Maybe I’ll just try and do a subset for now.

Luckily a lot of them look like standard functions that SEMS can natively implement. Or at least reasonably simple code can make it happen.

By way of background I’ve already written SEMS applications that handle multiple simultaneous calls – this in conjunction with heavily tricked out networks of kamailio servers.

My plan now I guess is to look very closely at the SEMS SBC and see what can be done with it.

The basic model will be a Kamailio proxy handling PSTN upstream trunking (SIP trunking) and local and remote UA registrations.

Incoming trunked calls will be landed on the SEMS instance which will then make a new outgoing call to registered handsets. Local PBX calls will similarly be routed by Kamailio and hosted on the SEMS instance. This is pretty much the same model as described in the freeswitch implementation at


The difference is that SEMS will act as the SBC and media server. In addition I plan to implement MWI natively in SEMS, plus busy-lamp functionality using the kamailio resource list server and publish commands from SEMS.

More to follow when I learn all about SEMS sbc.

SER aliases dbtext file format and example values

2007 f 19

Today I needed to get Sip Express Router to work with a preconfigured set of aliases. I have a project where there is a very small wafer PC running SER out of flash. The configuration is completely static and I have no need or wish to use MySQL to record this stuff.

I have chosen to use 0.9.6 SER as that seems to be the latest stable.

First port of call was the SER site where I checked out the module documentation for dbtext http://www.iptel.org/ser/doc/modules/dbtext . It was kind of minimal. In particular it didn’t tell me what I needed to know – which fields in the dbtext aliases example were needed and what values should be in them.

I also rapidly discovered that the example configuration file had problems such as wrong module paths.

To cut a long story short (and a horror experience getting mysql going to capture the table contents from ser aliases generated by serctl ) I ended up with the following files in /tmp/serdb. Of particular note is the need to \ the : character in the sip contact field as that is also the dbtext field separator.

In the aliases file username is the text of the alias and contact is where it is routed to – with sip: preceding the actual contact. All other fields should be as listed below – the 2000000000 field entries represent times and dates in the hopefully distant future


username(str) domain(str,null) contact(str,null) expires(int,null) q(double,null) callid(str,null) cseq(int,null) last_modified(str) replicate(int,null) state(int,null) flags(int) user_agent(str) received(str,null)
1002::sip\\:1009@example.org:2000000000:1.0:FourtyTwo:42:2000000000:0:0:128:SIP Express Router FIFO::
1003::sip\\:1009@example.org:2000000000:1.0:FourtyTwo:42:2000000000:0:0:128:SIP Express Router FIFO::
1004::sip\\:1009@example.org:2000000000:1.0:FourtyTwo:42:2000000000:0:0:128:SIP Express Router FIFO::


username(str) password(str) ha1(str) domain(str) ha1b(str) rpid(str)


table_name(str) table_version(int)


username(str) domain(str,null) contact(str,null) expires(int,null) q(double,null) callid(str,null) cseq(int,null) last_modified(str) replicate(int,null) state(int,null) flags(int) user_agent(str) received(str)

To complement these I had a sercfg set up with correct paths as follows


# simple quick-start config script with dbtext and correct paths for ser-0.9.6

# ----------- global configuration parameters ------------------------

#debug=9         # debug level (cmd line: -dddddddddd)
#log_stderror=no        # (cmd line: -E)

check_via=no    # (cmd. line: -v)
dns=no          # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)




# ------------------ module loading ----------------------------------

# use dbtext database
loadmodule "/usr/local/lib/ser/modules/dbtext.so"

loadmodule "/usr/local/lib/ser/modules/sl.so"
loadmodule "/usr/local/lib/ser/modules/tm.so"
loadmodule "/usr/local/lib/ser/modules/rr.so"
loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
loadmodule "/usr/local/lib/ser/modules/usrloc.so"
loadmodule "/usr/local/lib/ser/modules/registrar.so"
loadmodule "/usr/local/lib/ser/modules/textops.so"

# modules for digest authentication
loadmodule "/usr/local/lib/ser/modules/auth.so"
loadmodule "/usr/local/lib/ser/modules/auth_db.so"

# ----------------- setting module-specific parameters ---------------

# -- usrloc params --

# use dbtext database for persistent storage
modparam("usrloc", "db_mode", 1)
modparam("usrloc|auth_db", "db_url", "dbtext:///tmp/serdb")

# -- auth params --
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "user_column", "username")
modparam("auth_db", "domain_column", "domain")

# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# -------------------------  request routing logic -------------------

# main routing logic

    # initial sanity checks -- messages with
    # max_forwards==0, or excessively long requests
    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483","Too Many Hops");
    if (msg:len >=  max_len ) {
        sl_send_reply("513", "Message too big");

    # we record-route all messages -- to make sure that
    # subsequent messages will go through our proxy; that's
    # particularly good if upstreami and downstreami entities
    # use different transport protocol
    if (!method=="REGISTER") record_route();

    # subsequent messages withing a dialogi should take the
    # path determined by record-routing
    if (loose_route()) {
        # mark routing logic in request
        append_hf("P-hint: rr-enforcedrn");

    if (!uri==myself) {
        # mark routing logic in request
        append_hf("P-hint: outboundrn");

    # if the request is for other domain use UsrLoc
    # (in case, it does not work, use the following command
    # with proper names and addresses in it)
    if (uri==myself) {
        if (method=="REGISTER") {
            # digest authentication
            if (!www_authorize("", "subscriber")) {
                www_challenge("", "0");


        if (!uri==myself) {
            append_hf("P-hint: outbound aliasrn");

        # native SIP destinations are handled using our USRLOC DB
        if (!lookup("location")) {
            sl_send_reply("404", "Not Found");
    append_hf("P-hint: usrloc appliedrn");

    # send it out now; use stateful forwarding as it works reliably
    # even for UDP2TCP
    if (!t_relay()) {

Install qcad on Centos 5

2007 f 17

I spent some time today looking for CAD packages that work well on Linux.

I’ve used autocad before and it worked O.K. but took some getting used to. I was hoping for something that was similar but not necessarily as powerful – autocad-lite or similar.

After some searching and tossing out many would-be contenders I found that qcad was moderately well regarded – as opposed to almost every other free CAD package which were ‘in development’ or simply abysmal.

Determined to install it on Centos 5 I downloaded the community edition source codes (qcad- . The instructions that came with it were non-existent so I chose a basic approach.

Copy the downloaded file qcad- to /usr/local/src


cd /usr/local/src
tar -xzf qcad-
rm -f qcad-
cd qcad-

after a bit of poking around I found the scripts directory

cd scripts

This didn’t work due to an error

error: ISO C++ does not support ‘long long’

A bit of searching and I discovered a simple fix

cd /usr/local/src/qcad-
nano defs.pro

then comment out lines 2 and 3 thus

#QMAKE_CXXFLAGS += -pedantic

It seems that the -pedantic causes problems handling long long.

Re-running the build script


I get an error

sh: ./release_translations.sh: No such file or directory
Building qcad binary failed

More searching and another easy fix

./build_qcad.sh notrans

Finally it all built. But it wasn’t integrated with gnome or kde. How to make this happen will be another journal entry. For now start a terminal session

cd /usr/local/src/qcad-

And then the qcad program starts up. On initial inspection it seems to be O.K. with no malformed windows/text or obscure start messages. The real problem is how to use it. I am sure there are tutorials, but there is nothing intuitive in the program – unlike other graphics packages I have used.

More information later when I figure this guy out.