[Kamailio-Users] prepaid system

Peter Lemenkov lemenkov at gmail.com
Mon Dec 29 12:51:42 CET 2008

Hello All!

2008/12/23, igor <igor at carneiro.cc>:
>  I need implement a prepaid system in my kamilio !
>  anybody help me !?
>  any information !

I also share some bits about our architecture, we currently use at ipport.net.

We using OpenSER (1.3.x) as SIP-proxy and registrar. Every information
about users (their accounting data, such as currently established
calls, and authorization data) stored in Oracle.

* User authorizes via radius (freeradius with oracle module).

* At the time of user calls somewhere, we (after checking its auth
data) rewrite its URI using custom plugin for OpenSER (which utilizes
libsqlora8 library). It's not a rocket science, and (in simplified
form) it looks like the following:


                subst_pvar (m, fU, "$fU");
                subst_pvar (m, tU, "$tU");
                subst_pvar (m, fd, "$fd");
                subst_pvar (m, td, "$td");

                sqlo_prepare(handle, stmt);


                if((sqlo_execute(sth, 1) != SQLO_SUCCESS){
                                        LM_ERR("execute FAILED\n");
                                        return -1;

                sprintf (request_uri, "sip:%s@%s", tU, td);
                a.type = SET_URI_T;
                a.elem[0].type = STRING_ST;
                a.elem[0].u.string = request_uri;
                a.next = NULL;

                if (do_action (&a, m) < 0){
                        LM_ERR("do_action FAILED\n");
                        return -1;


If user runs out of money/limit of simultaneous calls/requests for
disabled feature we'll forward him to predefined SEMS address with
proper message describing current sutiation "sorry, you have no
money", "you didn't pay for talk with girls", "you didn't vote for
Obama, so we disconnecting you!".

* In order to control rtp between clients (and therefore disconnect
them in case of network failure) we using Cisco 28xx routers (
http://www.cisco.com/en/US/products/ps5854/ ), but we currently moving
to our custom solution based on our rtp proxy server, since Cisco
can't deliver enough calls processing performance for their price.

* In order to drop calls when user runs out of its credit, we use
PL/SQL scripts in Oracle + OpenSER's fifo.

* For some particular tasks we also using Sippy B2BUA as B2BUA solution.

That's all, folks.

With best regards!

More information about the Users mailing list