[OpenSIPS-Users] A2Billing Integration

Juan Asencio juan at asencio.dk
Sun Feb 15 09:19:44 CET 2009


Rafael RGV wrote:
> Hi Juan
> Its not a horrible solution, actually we are using both, Opensips and 
> Asterisk (with a2billing AGI) in a heavy production environment for 
> pre/post wholesale billing and I can control almost everything from 
> a2billing admin interface.
>
> Try this procedure:
>
> You can use a mysql VIEW for 'opensips subscriber table' from 
> 'a2billing user table' to facilitate opensips users provisioning from 
> a2billing admin/user web interfaces.
>
> For example, Sip proxy Opensips IP: 192.1689.12.254
> DB: 192.168.1.29
> A2billing DB: a2billing
> A2billing subscriber table: cc_card
>
> In mysql console:
>
> USE opensips;
>
> CREATE VIEW opensips.subscriber_v1 AS
> SELECT id AS id,
> useralias AS username,
> '192.168.12.254' AS domain,
> userpass AS password,
> email AS email_address,
> md5(concat(useralias,' : ','192.168.12.254',' : ',userpass)) AS ha1,
> md5(concat(useralias,'@','192.168.12.254',' : ','192.168.12.254',' : 
> ',userpass)) AS ha1b,
> useralias AS rpid from a2billing.cc_card WHERE tariff=2;
>
> INSERT INTO version (table_name,table_version) VALUES 
> ('subscriber_v1','6');
>
>
> Then in your opensips config file note that you have to indicate the 
> new table 'subscriber_v1' as follows:
>
> .
> .
> .
> # Tablas 'uri' y tabla 'subscriber'
> loadmodule "uri_db.so"
> modparam("uri_db", "db_url", 
> "mysql://opensips:******@192.168.1.29/opensips 
> <http://192.168.1.29/opensips>")
> modparam("uri_db", "db_table", "subscriber_v1")
> .
> ...
> ########################################################################
> # Request route 'base-route-REGISTER'
> ########################################################################
> route[2]
> {
>     sl_send_reply("100", "Trying");
>     if(!www_authorize("", "subscriber_v1"))
>     # Nota: tabla 'subscriber_v1' es un VIEW de mya2billing.cc_card
>     {
>         # xlog("L_INFO", "Register authentication failed - M=$rm 
> RURI=$ru F=$fu T=$tu IP=$si ID=$ci UA=$ua \n");
>         xlog("L_INFO", "Register authentication failed - F=$fu IP=$si 
> UA=$ua \n");
>         www_challenge("", "0");
>         exit;
>     }
>     if(!check_to()) ...
> .
> .
> .
> #########################################################################
> # Request route 'base-route-INVITE'
> #########################################################################
> route[4]
> {
>     log(1," route[4]---> INVITE Message Handler \n");
>     sl_send_reply("100", "Trying");
>     if(from_gw())  ## verifica si la llamada viene de alguno de los 
> GWs, tabla 'lcr'
>     {
>         xlog("L_INFO", "Call from PSTN - M=$rm RURI=$ru F=$fu T=$tu 
> IP=$si ID=$ci\n");
>         setflag(23);
>     }
>     else
>     {
>         if(allow_trusted())  ## Si la llamada no viene del GW, 
> verifica si el ip de origen esta en la tabla 'trusted'
>         {
>             xlog("L_INFO", "Call from trusted peer - M=$rm RURI=$ru 
> F=$fu T=$tu IP=$si ID=$ci\n");
>             if(!is_domain_local("$rd"))
>             {
>                 xlog("L_INFO", "Rejecting peering attempt with 
> non-local request domain - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
>                 sl_send_reply("403", "Relaying Denied");
>                 exit;
>             }
>             setflag(23);
>         }
>         else ## => Si no viene del GW o de algun UA en 'trusted' 
> entonces la llamada se origina en el sip server y debe autenticarse:
>         {
>             if(!proxy_authorize("", "subscriber_v1"))
>             {
>                 xlog("L_INFO", "Proxy authentication failed - M=$rm 
> RURI=$ru F=$fu T=$tu IP=$si ID=$ci UA=$ua \n\n");
>                 proxy_challenge("", "0");
>                 exit;
>             }
>             if(!check_from())
> .
> .
> .
>
> Good luck!
> Rafael
>
> PS: I also want to know why some people think its a horrible 
> solution... I think its the best.
>
>
> On Tue, Feb 10, 2009 at 10:21 AM, Juan Asencio <juan at asencio.dk 
> <mailto:juan at asencio.dk>> wrote:
>
>     Hi Raúl and list,
>
>     Could anyone explain a little bit, why the OpenSIPS+Asterisk+A2Billing
>     would be a horrible solution?
>
>     I'm new at this and I would like to learn and understand what kind of
>     problems could arise from such a solution.
>
>     Regards,
>
>     Juan.-
>
>     > El Lunes, 9 de Febrero de 2009 18:41, Gonzalo Gonzalez escribió:
>     >> May be I am not explaining myself right, but read this post:
>     >>
>     >> http://forum.asterisk2billing.org/viewtopic.php?t=2456
>     >>
>     >> I know people use the same database using database views.
>     >>
>     >> Thanks,
>     >>
>     >> Gonzalo
>     >
>     > Please, reply to the list, not to me directly.
>     >
>     > Talking about the issue .. that thread only said that you could
>     use the
>     > same
>     > DB throught views to have the same users on OpenSIPS and on
>     Asterisk,
>     > anything more.
>     >
>     > You could not do accounting/billing only with OpenSIPS and
>     A2Billing,
>     > that's
>     > what I told you, you need OpenSIPS+Asterisk+A2Billing and IHMO
>     that's a
>     > horrible solution, with lot of problems on you future.
>     >
>     > Regards
>     > --
>     > Raúl Alexis Betancor Santana
>     > Dimensión Virtual
>     >
>     > _______________________________________________
>     > Users mailing list
>     > Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>     > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     >
>
>
>
>     _______________________________________________
>     Users mailing list
>     Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>     http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
Rafael, thank you for the detail explanation.

If I get into trouble I will get back to you :)

Have a nice weekend,

Juan.-



More information about the Users mailing list