[Users] Please help me to fix openser.cfg (rewritehostport)

Daniel-Constantin Mierla daniel at voice-system.ro
Sat Oct 14 20:15:37 CEST 2006


Please keep the list in cc.

use

xlog("L_ERR", "$rm is next to pass for transfer to Asterisk");

maybe you got the log message for another request, the syntax looks ok.

Cheers,
Daniel


On 10/13/06 14:38, Ronald Wiplinger wrote:
> Daniel-Constantin Mierla wrote:
>> I am not sure what do you want to achieve, but I assume it should be 
>> before lookup("aliases");
>
> I want that if I dial a number, like 601, it should go to another 
> machine, where Asterisk is running and a phone with 601 is connected.
>
> I have moved the paragraph just before the lookup("aliases"); 
>                        save("location");
>                        exit;
>                };
>
>                                xlog("L_ERR", "INVITE is next to pass 
> for transfer to Asterisk");
>                if (method=="INVITE") {
>                                xlog("L_ERR", "INVITE passed for 
> transfer to Asterisk");
>                        if (uri=~"^sip:601@") {
>                                rewritehostport("59.124.210.35:5060");
>                                xlog("L_ERR", "transfer to Asterisk");
>                                route(1);
>                                exit;
>                        };
>                };
>
>                lookup("aliases");
>
> With these three xlog statements, I get only the first one (INVITE is 
> next to pass for transfer to Asterisk). The next if is obviously not 
> fulfilled!
> Do I have a syntax error here?
>
>
> bye
>
> Ronald Wiplinger
>
>
>>
>> Cheers,
>> Daniel
>>
>>
>> On 10/12/06 17:01, Ronald Wiplinger wrote:
>>> I try to rewritehostport to my Asterisk box with all starting 
>>> numbers with 6. The xlog never shows anything.
>>>
>>>
>>>
>>>         if (method=="INVITE") {
>>>              if (uri=~"^sip:6.+@") {
>>>                    rewritehostport("xx.xx.xx.xx:5060");
>>>                                xlog("L_ERR", "transfer to Asterisk");
>>>                    route(1);
>>>                    exit;
>>>             };
>>>         };
>>>
>>> I believe I did not put it at the right place. Below is my entire 
>>> openser.cfg. Can you please tell me, where above paragraph should 
>>> be? Other parts maybe also not in the right order.
>>>
>>>
>>>
>>> bye
>>>
>>> Ronald Wiplinger
>>>
>>>
>>>
>>>
>>>
>>> #
>>> # $Id: openser.cfg,v 1.6 2006/02/15 18:23:46 bogdan_iancu Exp $
>>> #
>>>
>>> debug=3            # debug level (cmd line: -dddddddddd)
>>> fork=yes
>>> log_stderror=no    # (cmd line: -E)
>>> log_facility=LOG_LOCAL7
>>> log_name="Taipei-openser"
>>>
>>> check_via=no    # (cmd. line: -v)
>>> dns=no          # was no (cmd. line: -r)
>>> rev_dns=no      # (cmd. line: -R)
>>> port=5060
>>> children=4
>>> fifo="/tmp/openser_fifo"
>>>
>>>
>>> mpath="/usr/local/lib64/openser/modules/"
>>> loadmodule "mysql.so"
>>> loadmodule "sl.so"
>>> loadmodule "tm.so"
>>> loadmodule "rr.so"
>>> loadmodule "maxfwd.so"
>>> loadmodule "usrloc.so"
>>> loadmodule "registrar.so"
>>> loadmodule "textops.so"
>>> loadmodule "nathelper.so"
>>> loadmodule "xlog.so"
>>> loadmodule "enum.so"
>>> loadmodule "acc.so"
>>> loadmodule "auth.so"
>>> loadmodule "auth_db.so"
>>> modparam("usrloc|auth_db","db_url","mysql://shshshsh:shhhhrw@localhost/wodeopenser") 
>>> modparam("usrloc", "db_mode", 2)
>>> modparam("registrar", "nat_flag", 6)
>>> modparam("registrar", "sip_natping_flag", 7) modparam("auth_db", 
>>> "calculate_ha1", yes)
>>> modparam("auth_db", "password_column", "password")
>>> modparam("rr", "enable_full_lr", 1)
>>> modparam("nathelper", "rtpproxy_sock", "udp:xx.xx.xx.xx:22222")  # 
>>> default port 22222
>>> #modparam("nathelper", "rtpproxy_sock", 
>>> "unix:/var/run/rtpproxy.sock") modparam("nathelper", 
>>> "natping_interval", 30)
>>> modparam("nathelper", "ping_nated_only", 1)
>>> modparam("nathelper", "sipping_from", "sip:xx.xx.xx.xx") 
>>> modparam("enum", "domain_suffix", "e164.org.")
>>> modparam("enum", "tel_uri_params", ";npdi")
>>>
>>>
>>> # -------------------------  request routing logic -------------------
>>>
>>> # main routing logic
>>>
>>> route{
>>>     xlog("L_ERR", "request method: [$rm], from URI: [$fu], To URI: 
>>> [$tu]");
>>>     if (!mf_process_maxfwd_header("10")) {
>>>         sl_send_reply("483","Too Many Hops");
>>>         exit;
>>>     };
>>>
>>>     if (msg:len >=  4096 ) {
>>>         sl_send_reply("513", "Message too big");
>>>         exit;
>>>     };
>>>
>>>        # 
>>> -----------------------------------------------------------------
>>>     # NAT detection
>>>        # 
>>> -----------------------------------------------------------------
>>>     route(2);
>>>
>>>
>>>        # 
>>> -----------------------------------------------------------------
>>>     # if you want to make ENUM work with numbers starting with "00",
>>>     # use the following to convert "00" it into a "+"
>>>        # 
>>> -----------------------------------------------------------------
>>>
>>>
>>>     if (uri=~"^sip:00[1-9][0-9]*@") {                 strip(2);
>>>         prefix("+");
>>>     };
>>>     if (uri=~"sip:\+[0-9]+@") {                          
>>> if(!enum_query("e164.arpa.") && !enum_query("e164.org.")  && 
>>> !enum_query("e164.info.") && !enum_query("enum.org."))
>>>                        {
>>>                                xlog("L_ERR", "Invalid enum? $uri 
>>> Route to PSTN");
>>>                        };
>>>         xlog("L_ERR","we matched just number $tu");
>>>         strip(1);    # remove +
>>>          t_relay();
>>>         exit;
>>>     };
>>>        # 
>>> -----------------------------------------------------------------
>>>     if (!method=="REGISTER")
>>>         record_route();
>>>
>>>     if (loose_route()) {
>>>         # mark routing logic in request
>>>         append_hf("P-hint: rr-enforced\r\n");         route(1);
>>>     };
>>>
>>>     # -----------------------------------------------------------------
>>>     # Call Type Processing Section
>>>     # -----------------------------------------------------------------
>>>     if (!uri==myself) {
>>>         route(1);
>>>     };
>>>
>>>     # -----------------------------------------------------------------
>>>     if (uri==myself) {
>>>
>>>         if (method=="REGISTER") {
>>>             if (!www_authorize("taipei.example.net", "subscriber")) {
>>>                 www_challenge("taipei.example.net", "0");
>>>                 exit;
>>>             };
>>>
>>>             if (isflagset(5)) {
>>>             setflag(6);
>>>             };
>>>
>>>             save("location");
>>>             exit;
>>>         };
>>>
>>>         lookup("aliases");
>>>         if (!uri==myself) {
>>>             append_hf("P-hint: outbound alias\r\n");             
>>> route(1);
>>>         };
>>>
>>>         if (!lookup("location")) {
>>>             sl_send_reply("404", "Not Found");
>>>             exit;
>>>         };
>>>         append_hf("P-hint: usrloc applied\r\n");
>>>         if (method=="INVITE") {
>>>              if (uri=~"^sip:6.+@") {
>>>                    rewritehostport("xx.xx.xx.xx:5060");
>>>                                xlog("L_ERR", "transfer to Asterisk");
>>>                    route(1);
>>>                    exit;
>>>             };
>>>         };     };
>>>
>>>     route(1);
>>> }
>>>
>>>
>>> route[1] {
>>>     if (subst_uri('/(sip:.*);nat=yes/\1/')){
>>>     setflag(6);
>>>     };
>>>
>>>     if (isflagset(5)||isflagset(6)) {
>>>     route(3);
>>>     }
>>>     if (!t_relay()) {
>>>         sl_reply_error();
>>>     };
>>>     exit;
>>> }
>>>
>>>
>>> route[2]{
>>>     force_rport();
>>>     if (nat_uac_test("19")) {
>>>         if (method=="REGISTER") {
>>>             fix_nated_register();
>>>         } else {
>>>             fix_nated_contact();
>>>         };
>>>         setflag(5);
>>>     };
>>> }
>>>
>>>
>>> route[3] {
>>>     if (is_method("BYE|CANCEL")) {
>>>         unforce_rtp_proxy();
>>>     } else if (is_method("INVITE")){
>>>         force_rtp_proxy();
>>>         t_on_failure("1");
>>>     };
>>>     if (isflagset(5))
>>>         search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
>>>         t_on_reply("1");
>>>     }
>>>
>>>     failure_route[1] {
>>>     if (isflagset(6) || isflagset(5)) {
>>>         unforce_rtp_proxy();
>>>     }
>>> }
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at openser.org
>>> http://openser.org/cgi-bin/mailman/listinfo/users
>>>
>>
>>
>>
>> ---
>> avast! Antivirus: Inbound message clean.
>> Virus Database (VPS): 0641-3, 2006/10/12
>> Tested on: 2006/10/13 ¤U¤È 05:15:28
>> avast! - copyright (c) 1988-2006 ALWIL Software.
>> http://www.avast.com
>>
>>
>>
>>
>
>




More information about the sr-users mailing list