[OpenSIPS-Users] OpenSIPS hang - 1.6.3

James Lamanna jlamanna at gmail.com
Sun Oct 3 17:17:38 CEST 2010


Btw, this happens whenever I try to place a call.
It also crashes my phone, a Cisco 509G.

-- James

On Sun, Oct 3, 2010 at 8:05 AM, James Lamanna <jlamanna at gmail.com> wrote:
> Hi,
> I just had a situation where the opensips process has totally hung and
> now will not respond to SIP traffic.
> These are the last lines in the log file (debug=6)
>
> Oct  3 07:54:16 [27900] DBG:tm:update_totag_set: new totag
> Oct  3 07:54:16 [27900] DBG:tm:insert_timer_unsafe: [2]: 0x7f0a85d96698 (478)
> Oct  3 07:54:16 [27900] DBG:tm:run_trans_callbacks:
> trans=0x7f0a85d96618, callback type 128, id 0 entered
> Oct  3 07:54:16 [27900] DBG:dialog:next_state_dlg: dialog
> 0x7f0a85d81a88 changed from state 1 to state 3, due event 3
> Oct  3 07:54:16 [27900] DBG:dialog:dlg_onreply: dialog 0x7f0a85d81a88 confirmed
> Oct  3 07:54:16 [27900] DBG:dialog:insert_dlg_timer_unsafe: inserting
> 0x7f0a85d81ac0 for 43673
> Oct  3 07:54:16 [27900] DBG:dialog:ref_dlg: ref dlg 0x7f0a85d81a88 with 1 -> 3
> Oct  3 07:54:16 [27900] DBG:dialog:run_dlg_callbacks:
> dialog=0x7f0a85d81a88, type=8
> Oct  3 07:54:16 [27900] DBG:dialog:fetch_dlg_value: looking for <dlg_peer>
> Oct  3 07:54:16 [27900] DBG:dialog:fetch_dlg_value: var found->
> <"Voice Mail"<sip:99999 at x.x.x.x:5060>
>>!
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:__dialog_sendpublish:
> peer_uri = "Voice Mail"<sip:99999 at x.x.x.x:5060>
>
> Oct  3 07:54:16 [27900] DBG:core:parse_to: end of header reached, state=10
> Oct  3 07:54:16 [27900] DBG:core:parse_to: display={"Voice Mail"},
> ruri={sip:99999 at x.x.x.x:5060}
> Oct  3 07:54:16 [27900] DBG:dialog:fetch_dlg_value: looking for <dlginfo_flag>
> Oct  3 07:54:16 [27900] DBG:dialog:fetch_dlg_value: var NOT found!
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:__dialog_sendpublish: flag = D
> Oct  3 07:54:16 [27900] DBG:dialog:fetch_dlg_value: looking for <dlg_entity>
> Oct  3 07:54:16 [27900] DBG:dialog:fetch_dlg_value: var NOT found!
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:__dialog_sendpublish:
> dialog confirmed, from=sip:user at opensips.server
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:build_dialoginfo: new_body:
> <?xml version="1.0"?>
> <dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="0"
> state="full" entity="sip:user at opensips.server"><dialog
> id="5c7ed6ad-9d1a1e06 at 192.168.2.7"
> call-id="5c7ed6ad-9d1a1e06 at 192.168.2.7"
> direction="initiator"><state>confirmed</state><remote><identity
> display="Voice Mail">sip:99999 at x.x.x.x:5060</identity><target
> uri="sip:99999 at x.x.x.x:5060"/></remote><local><identity>sip:user at opensips.server</identity><target
> uri="sip:user at x.x.x.x"/></local></dialog></dialog-info>
>
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:print_publ: publ:
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:print_publ: uri=
> sip:user at opensips.server
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:print_publ: id= DIALOG_PUBLISH
> Oct  3 07:54:16 [27900] DBG:pua_dialoginfo:print_publ: expires= 43200
> Oct  3 07:54:16 [27900] DBG:pua:send_publish: pres_uri=sip:user at opensips.server
> Oct  3 07:54:16 [27900] DBG:pua:send_publish: Try to get hash lock [495]
> Oct  3 07:54:16 [27900] DBG:pua:send_publish: Got hash lock 495
> Oct  3 07:54:16 [27900] DBG:pua:search_htable: core_hash= 495
> Oct  3 07:54:16 [27900] DBG:pua:search_htable: Searched:
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  pres_uri=
> sip:user at opensips.server  len= 27
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  etag=  - len= 0
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  id= DIALOG_PUBLISH
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  expires= -1286117656
> Oct  3 07:54:16 [27900] DBG:pua:search_htable:
> Oct  3 07:54:16 [27900] DBG:pua:search_htable: Found
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  pres_uri=
> sip:user at opensips.server   len= 27
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  etag=
> a.1286117182.27900.2.0 - len= 22
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  id= DIALOG_PUBLISH
> Oct  3 07:54:16 [27900] DBG:pua:print_ua_pres:  expires= 3590
> Oct  3 07:54:16 [27900] DBG:pua:search_htable:
> Oct  3 07:54:16 [27900] DBG:pua:search_htable: no etag restriction
> Oct  3 07:54:16 [27900] DBG:pua:search_htable: found record
> Oct  3 07:54:16 [27900] DBG:pua:send_publish: record found in hash_table
> Oct  3 07:54:16 [27900] DBG:pua:send_publish: Try to get presentity
> lock 0x7f0a85d7dff0
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d7f9f8 next=0x7f0a85d796e8, timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d796e8 next=0x7f0a85d82db8, timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d82db8 next=0x7f0a85d88ed0, timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d88ed0 next=0x7f0a85d82ce0, timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d82ce0 next=0x7f0a85d8bdd8, timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d8bdd8 next=0x7f0a85d8d630, timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d8d630 next=(nil), timeout=473400000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d90890 next=(nil), timeout=473500000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d93788 next=0x7f0a85d94fe0, timeout=473600000
> Oct  3 07:54:16 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : request resending (t=0x7f0a85d93568, PUBLISH
> s ... )
> Oct  3 07:54:16 [27902] DBG:tm:set_timer: relative timeout is 1000000
> Oct  3 07:54:16 [27902] DBG:tm:insert_timer_unsafe: [5]:
> 0x7f0a85d93788 (474600000)
> Oct  3 07:54:16 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : done
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d94fe0 next=(nil), timeout=473600000
> Oct  3 07:54:16 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : request resending (t=0x7f0a85d94dc0, PUBLISH
> s ... )
> Oct  3 07:54:16 [27902] DBG:tm:set_timer: relative timeout is 1000000
> Oct  3 07:54:16 [27902] DBG:tm:insert_timer_unsafe: [5]:
> 0x7f0a85d94fe0 (474600000)
> Oct  3 07:54:16 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : done
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d96838 next=0x7f0a85d9d028, timeout=473700000
> Oct  3 07:54:16 [27902] DBG:tm:utimer_routine: timer
> routine:4,tl=0x7f0a85d9d028 next=(nil), timeout=473700000
> Oct  3 07:54:16 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : request resending (t=0x7f0a85d9ce08, PUBLISH
> s ... )
> Oct  3 07:54:16 [27902] DBG:tm:set_timer: relative timeout is 1000000
> Oct  3 07:54:16 [27902] DBG:tm:insert_timer_unsafe: [5]:
> 0x7f0a85d9d028 (474700000)
> Oct  3 07:54:16 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : done
> Oct  3 07:54:17 [27902] DBG:tm:utimer_routine: timer
> routine:5,tl=0x7f0a85d93788 next=0x7f0a85d94fe0, timeout=474600000
> Oct  3 07:54:17 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : request resending (t=0x7f0a85d93568, PUBLISH
> s ... )
> Oct  3 07:54:17 [27902] DBG:tm:set_timer: relative timeout is 2000000
> Oct  3 07:54:17 [27902] DBG:tm:insert_timer_unsafe: [6]:
> 0x7f0a85d93788 (476600000)
> Oct  3 07:54:17 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : done
> Oct  3 07:54:17 [27902] DBG:tm:utimer_routine: timer
> routine:5,tl=0x7f0a85d94fe0 next=(nil), timeout=474600000
> Oct  3 07:54:17 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : request resending (t=0x7f0a85d94dc0, PUBLISH
> s ... )
> Oct  3 07:54:17 [27902] DBG:tm:set_timer: relative timeout is 2000000
> Oct  3 07:54:17 [27902] DBG:tm:insert_timer_unsafe: [6]:
> 0x7f0a85d94fe0 (476600000)
> Oct  3 07:54:17 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : done
> Oct  3 07:54:17 [27902] DBG:tm:utimer_routine: timer
> routine:5,tl=0x7f0a85d9d028 next=(nil), timeout=474700000
> Oct  3 07:54:17 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : request resending (t=0x7f0a85d9ce08, PUBLISH
> s ... )
> Oct  3 07:54:17 [27902] DBG:tm:set_timer: relative timeout is 2000000
> Oct  3 07:54:17 [27902] DBG:tm:insert_timer_unsafe: [6]:
> 0x7f0a85d9d028 (476700000)
> Oct  3 07:54:17 [27902] DBG:tm:retransmission_handler:
> retransmission_handler : done
>
> Here is my config file:
>
> #
> # $Id: nathelper.cfg 5503 2009-03-22 16:22:32Z bogdan_iancu $
> #
> # simple quick-start config script including nathelper support
>
> # This default script includes nathelper support. To make it work
> # you will also have to install Maxim's RTP proxy. The proxy is enforced
> # if one of the parties is behind a NAT.
> #
> # If you have an endpoing in the public internet which is known to
> # support symmetric RTP (Cisco PSTN gateway or voicemail, for example),
> # then you don't have to force RTP proxy. If you don't want to enforce
> # RTP proxy for some destinations than simply use t_relay() instead of
> # route(1)
> #
> # Sections marked with !! Nathelper contain modifications for nathelper
> #
> # NOTE !! This config is EXPERIMENTAL !
> #
> # ----------- global configuration parameters ------------------------
>
> debug=3         # debug level (cmd line: -dddddddddd)
> fork=yes
> log_stderror=no # (cmd line: -E)
> log_facility=LOG_LOCAL0
> tos=0x60
>
> # Uncomment these lines to enter debugging mode
> fork=no
> log_stderror=yes
> debug=6
>
> check_via=no    # (cmd. line: -v)
> dns=no           # (cmd. line: -r)
> rev_dns=no      # (cmd. line: -R)
> port=5060
> children=4
>
> listen=udp:opensips.server:5060
> listen=udp:opensips.server:5061
> # ------------------ module loading ----------------------------------
>
> #set module path
> #mpath="/usr/local/lib/opensips/modules/"
> mpath="/usr/local/lib64/opensips/modules/"
>
> # Uncomment this if you want to use SQL database
> loadmodule "db_mysql.so"
>
> loadmodule "sl.so"
> loadmodule "maxfwd.so"
> loadmodule "textops.so"
> loadmodule "avpops.so"
> loadmodule "tm.so"
> loadmodule "rr.so"
> loadmodule "dialog.so"
> loadmodule "signaling.so"
> loadmodule "options.so"
> loadmodule "localcache.so"
>
> loadmodule "usrloc.so"
>
> loadmodule "presence.so"
> loadmodule "presence_xml.so"
> loadmodule "presence_dialoginfo.so"
> loadmodule "pua.so"
> loadmodule "pua_dialoginfo.so"
> #loadmodule "pua_bla.so"
> loadmodule "pua_usrloc.so"
>
> loadmodule "registrar.so"
> loadmodule "mi_fifo.so"
> #loadmodule "xlog.so"
>
> # Uncomment this if you want digest authentication
> # db_mysql.so must be loaded !
> loadmodule "auth.so"
> loadmodule "auth_db.so"
>
> # !! Nathelper
> loadmodule "nathelper.so"
>
> loadmodule "stun.so"
>
>
> # ----------------- setting module-specific parameters ---------------
>
> # -- mi_fifo params --
> modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
>
> modparam("usrloc", "db_mode", 2)
> modparam("usrloc|dialog|dispatcher|presence|presence_xml|pua|avpops",
>        "db_url", "mysql://opensips:xxxxxx@localhost/opensips")
>
>
> modparam("avpops","avp_table","usr_preferences")
>
> #modparam("dispatcher", "force_dst", 1)
> # Only use username
> #modparam("dispatcher", "flags", 1)
>
> # Store passwords for 1 hour in cache
>
> modparam("auth","username_spec","$avp(i:54)")
> modparam("auth","password_spec","$avp(i:55)")
> modparam("auth","calculate_ha1",1)
>
> modparam("auth_db", "db_url",
>        "mysql://opensipsro:xxxxxxx@localhost/opensips")
> modparam("auth_db", "calculate_ha1", yes)
> modparam("auth_db", "password_column", "password")
> modparam("auth_db", "load_credentials", "$avp(i:55)=password")
>
> modparam("rr", "enable_full_lr", 1)
>
> modparam("dialog", "dlg_flag", 4)
> modparam("dialog", "profiles_with_value", "caller")
>
> modparam("usrloc","nat_bflag",6)
> modparam("nathelper","sipping_bflag",8)
> #modparam("nathelper", "natping_interval", 30)
> modparam("nathelper", "ping_nated_only", 1)   # Ping only clients behind NAT
> #modparam("nathelper", "natping_interval", 30)
> modparam("nathelper", "sipping_from", "sip:pinger at opensips.server")
> modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy/rtpproxy.sock")
>
> modparam("presence", "server_address", "sip:sa at opensips.server:5060")
> modparam("presence", "expires_offset", 10)
> #modparam("presence", "fallback2db", 1)
> modparam("presence_xml", "force_active", 1)
>
> modparam("presence_dialoginfo", "force_single_dialog", 1)
> modparam("pua_dialoginfo", "presence_server", "sip:sa at opensips.server:5060")
> modparam("pua_dialoginfo", "include_callid", 1)
> modparam("pua_dialoginfo", "include_tags", 1)
> modparam("pua_dialoginfo", "caller_confirmed", 1)
>
> modparam("pua_usrloc", "default_domain",  "opensips.server")
> modparam("pua_usrloc", "presence_server", "sip:sa at opensips.server:5060")
>
> modparam("stun","primary_ip","opensips.server")
> modparam("stun","alternate_ip","opensips.server2")
> modparam("stun","primary_port","5060")
> modparam("stun","alternate_port","3479")
>
> # -------------------------  request routing logic -------------------
>
> # main routing logic
>
> route{
>
>        if (!is_method("NOTIFY"))
>                xlog("L_INFO", "New request - Request/failure/branch routes: M=$rm
> RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
>
>        # max_forwards==0, or excessively long requests
>        if (!mf_process_maxfwd_header("10")) {
>                sl_send_reply("483","Too Many Hops");
>                exit;
>        };
>        if (msg:len >=  2048 ) {
>                sl_send_reply("513", "Message too big");
>                exit;
>        };
>
>        # !! Nathelper
>        # Special handling for NATed clients; first, NAT test is
>        # executed: it looks for via!=received and RFC1918 addresses
>        # in Contact (may fail if line-folding is used); also,
>        # the received test should, if completed, should check all
>        # vias for rpesence of received
>        if (nat_uac_test("3")) {
>                # Allow RR-ed requests, as these may indicate that
>                # a NAT-enabled proxy takes care of it; unless it is
>                # a REGISTER
>
>                if (is_method("REGISTER") || !is_present_hf("Record-Route")) {
>                        #xlog("L_INFO", "LOG:Someone trying to register from private IP,
> rewriting\n");
>                        #xlog("L_INFO", "$rb\n");
>                        # This will work only for user agents that support symmetric
>                        # communication. We tested quite many of them and majority is
>                        # smart enough to be symmetric. In some phones it takes a
>                        # configuration option. With Cisco 7960, it is called
>                        # NAT_Enable=Yes, with kphone it is called "symmetric media" and
>                        # "symmetric signalling".
>
>                        # Rewrite contact with source IP of signalling
>                        fix_nated_contact();
>                        if ( is_method("INVITE") ) {
>                                #xlog("L_INFO", "NAT: FIXING SDP");
>                                fix_nated_sdp("1"); # Add direction=active to SDP
>                        };
>                        force_rport(); # Add rport parameter to topmost Via
>                        setbflag(6);    # Mark as NATed
>
>                        # if you want sip nat pinging
>                        # setbflag(8);
>                };
>        };
>
>        # subsequent messages withing a dialog should take the
>        # path determined by record-routing
>        if (loose_route()) {
>                # mark routing logic in request
>                append_hf("P-hint: rr-enforced\r\n");
>                route(1);
>                exit;
>        };
>
>        # we record-route all messages -- to make sure that
>        # subsequent messages will go through our proxy; that's
>        # particularly good if upstream and downstream entities
>        # use different transport protocol
>        if (!is_method("REGISTER"))
>                record_route();
>
>        if (method == "INVITE") {
>                setflag(4);
>        }
>
>        if (!uri==myself) {
>                # mark routing logic in request
>                append_hf("P-hint: outbound\r\n");
>                route(1);
>                exit;
>        };
>
>        # 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 (is_method("OPTIONS") && (! uri=~"sip:.*[@]+.*")) {
>                        options_reply();
>                        exit;
>                }
>
>                if (is_method("INVITE|ACK")) {
>                        unforce_rtp_proxy();
>                }
>
>
>
>                if (is_method("REGISTER")) {
>                        #xlog("L_INFO", "trying to register $au $ad\n");
>
>                        if(cache_fetch("local","passwd_$tu",$avp(i:55))) {
>                                $avp(i:54) = $tU;
>                                xlog("SCRIPT: stored password is $avp(i:55)\n");
>                                # perform auth from variables
>                                # $avp(i:54) contains the username
>                                # $avp(i:55) contains the password
>                                if (!pv_www_authorize("asterisk")) {
>                                        # authentication failed -> do challenge
>                                        www_challenge("asterisk", "0");
>                                        exit;
>                                };
>                        } else {
>                                # perform DB authentication ->
>                                # password will be loaded from DB automatically
>                                if (!www_authorize("asterisk", "subscriber")) {
>                                        # authentication failed -> do challenge
>                                        www_challenge("asterisk", "0");
>                                        exit;
>                                };
>                                # after DB authentication, the password is available
>                                # in $avp(i:55) because of the "load_credentials"
>                                # module parameter.
>                                xlog("SCRIPT: storing password <$avp(i:55)>\n");
>                                # use a 20 minutes lifetime for the password;
>                                # after that, it will erased from cache and we do
>                                # db authentication again (refresh the passwd from DB)
>                                cache_store("local","passwd_$tu","$avp(i:55)",3600);
>                        }
>
>                        # Uncomment this if you want to use digest authentication
>                        #if (!www_authorize("asterisk", "subscriber")) {
>                        #       www_challenge("asterisk", "0");
>                        #       return;
>                        #};
>
>                        #bla_set_flag();
>
>                        save("location");
>                        pua_set_publish();
>                        exit;
>                };
>
>                lookup("aliases");
>                if (!uri==myself) {
>                        append_hf("P-hint: outbound alias\r\n");
>                        route(1);
>                        exit;
>                };
>
>                #xlog("L_INFO", "TESTING FOR $hdr(Event)\n");
>                if (is_method("NOTIFY") && $hdr(Event) == "message-summary") {
>                        #xlog("L_INFO", "MWI Notification $rb\n");
>                        if (!lookup("location")) {
>                                sl_send_reply("404", "Not Found");
>                                exit;
>                        }
>                } else if (is_method("SUBSCRIBE") && (uri =~
> "sip:[7-9][0-9]@opensips.server" ||
>                                $hdr(Event) == 'message-summary')) {
>                        xlog("L_INFO", "SUBSCRIBE FOR PAGE/VM \n");
>                        if(!cache_fetch("local","ast_$fU",$avp(i:200)))
>                                avp_db_load("$fu/username","$avp(i:200)");
>                        if ($avp(i:200) == NULL || $avp(i:200) == '') {
>                                xlog("INVALID DIALPLAN SERVER URL\n");
>                                sl_send_reply("404", "Not Found");
>                                exit;
>                        } else {
>                                cache_store("local","ast_$fU","$avp(i:200)",3600);
>                        }
>                        #rewritehostport("$avp(i:200)");
>                        $rd = $(avp(i:200){s.select,0,:});
>                        $rp = $(avp(i:200){s.select,1,:});
>                } else if (is_method("PUBLISH|SUBSCRIBE|NOTIFY")) {
>                        route(2);
>
>                # Asterisk signaling comes in on 5061
>                } else if (dst_port==5061) {
>                        if (is_method("INVITE")) {
>                                dialoginfo_set();
>                        }
>
>                        if (!lookup("location")) {
>                                sl_send_reply("404", "Not Found");
>                                exit;
>                        }
>
>                        xlog("L_INFO", "request from asterisk $ru $tu\n");
>                        if (to_uri =~ ".*intercom=true") {
>                                xlog("INTERCOM REQUEST\n");
>                                $var(checkuser) = $tU;
>
>                                get_profile_size("caller","$var(checkuser)","$var(rcalls)");
>                                if ($var(rcalls) > 0) {
>                                        xlog("DENY INTERCOM\n");
>                                        sl_send_reply("486", "Busy Here");
>                                        exit;
>                                }
>                        }
>
>                        if (!isflagset(31)) {
>                                #get_profile_size("caller","$avp(s:caller_uuid)","$var(calls)");
>                                create_dialog();
>                                #set_dlg_profile("caller","$avp(s:caller_uuid)");
>                                set_dlg_profile("caller","$tU");
>                                setflag(31);
>                                get_profile_size("caller","$tU","$var(calls)");
>                                xlog("NUM CALLS $tU $ru $mf $var(calls) \n");
>                        }
>                } else if (is_method("INVITE")) {
>                        #if (!proxy_authorize("asterisk", "subscriber")) {
>                        #       proxy_challenge("asterisk", "1");  # Realm will be autogenerated
>                        #       exit;
>                        #};
>
>                        if(!cache_fetch("local","ast_$fU",$avp(i:200)))
>                                avp_db_load("$fu/username","$avp(i:200)");
>                        if ($avp(i:200) == NULL || $avp(i:200) == '') {
>                                xlog("INVALID DIALPLAN SERVER URL\n");
>                                sl_send_reply("404", "Not Found");
>                                exit;
>                        } else {
>                                cache_store("local","ast_$fU","$avp(i:200)",3600);
>                        }
>                        #rewritehostport("$avp(i:200)");
>                        $rd = $(avp(i:200){s.select,0,:});
>                        $rp = $(avp(i:200){s.select,1,:});
>
>                        if (!isflagset(31)) {
>                                #get_profile_size("caller","$avp(s:caller_uuid)","$var(calls)");
>                                create_dialog();
>                                #set_dlg_profile("caller","$avp(s:caller_uuid)");
>                                set_dlg_profile("caller","$fU");
>                                setflag(31);
>                                get_profile_size("caller","$fU","$var(calls)");
>                                xlog("NUM CALLS $fU $ru $mf $var(calls) \n");
>                        }
>                        dialoginfo_set();
>                }
>        };
>        append_hf("P-hint: usrloc applied\r\n");
>
>        route(1);
> }
>
> route[1]
> {
>        # !! Nathelper
>        if (uri=~"[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" &&
> !search("^Route:")){
>                sl_send_reply("479", "We don't forward to private IP addresses");
>                exit;
>        };
>
>        # if client or server know to be behind a NAT, enable relay
>        if (isbflagset(6)) {
>                force_rtp_proxy();
>        };
>
>        # NAT processing of replies; apply to all transactions (for example,
>        # re-INVITEs from public to private UA are hard to identify as
>        # NATed at the moment of request processing); look at replies
>        t_on_reply("1");
>
>        # send it out now; use stateful forwarding as it works reliably
>        # even for UDP2TCP
>        if (!t_relay()) {
>                sl_reply_error();
>        };
> }
>
> # !! Nathelper
> onreply_route[1] {
>        # NATed transaction ?
>        if (isbflagset(6) && status =~ "(183)|2[0-9][0-9]") {
>                fix_nated_contact();
>                force_rtp_proxy();
>        # otherwise, is it a transaction behind a NAT and we did not
>        # know at time of request processing ? (RFC1918 contacts)
>        } else if (nat_uac_test("1")) {
>                fix_nated_contact();
>        } else if (status =~ "407") {
>                xlog("AUTH unset profile $tu $fu\n");
>                unset_dlg_profile("caller","$fU");
>        }
> }
>
> route[2] {
>        xlog("L_INFO", "NOTIFY SUBSCRIBE PUBLISH route\n");
>        if (!t_newtran()) {
>                sl_reply_error();
>                exit;
>        };
>
>        if(is_method("PUBLISH")) {
>                if ($hdr(Sender) != NULL)
>                        handle_publish("$hdr(Sender)");
>                else
>                        handle_publish();
>        }
>        else if( is_method("SUBSCRIBE")) {
>                xlog("L_INFO", "Handle Subscribe\n");
>                handle_subscribe();
>        }
>        else if (is_method("NOTIFY")) {
> #               bla_handle_notify();
>                pua_update_contact();
>                t_reply("200", "OK");
>        }
>
>        exit;
> }
>
> -- James
>



More information about the Users mailing list