[OpenSIPS-Users] Getting Error when using NATHELPER module

Ahmed Munir ahmedmunir007 at gmail.com
Mon May 3 09:08:30 CEST 2010


Hi,

I'm getting error when I configured Nathelper on OpenSIPs, the errors are
listed down below;

May  3 05:44:43 newtest /usr/local/sbin/opensips[2999]:
ERROR:nathelper:select_rtpp_node: script error -no valid set selected
May  3 05:44:43 newtest /usr/local/sbin/opensips[2999]:
ERROR:nathelper:force_rtp_proxy_body: no available proxies
May  3 05:45:04 newtest /usr/local/sbin/opensips[2998]:
ERROR:nathelper:force_rtp_proxy: Unable to parse body

and my configuration of OpenSIPs is listed below;

loadmodule "dispatcher.so"
loadmodule "avpops.so"
loadmodule "permissions.so"
loadmodule "aaa_radius.so"
loadmodule "auth_aaa.so"
#loadmodule "auth_diameter.so"
loadmodule "nathelper.so"


#--------------------------------Settings For
Radius-------------------------------------
#modparam("auth_diameter", "diameter_client_host", "localhost")
modparam("aaa_radius",
"radius_config","/usr/local/etc/radiusclient-ng/radiusclient.conf")
modparam("acc", "aaa_url",
"radius:/usr/local/etc/radiusclient-ng/radiusclient.conf")
modparam("acc", "aaa_flag", 2)
modparam("acc", "aaa_missed_flag", 3)
modparam("acc", "aaa_extra",    "User-Name=$Au; \
                                Calling-Station-Id=$from; \
                                Called-Station-Id=$to; \
                                Sip-Translated-Request-URI=$ruri; \
                                Sip-RPid=$avp(s:rpid); \
                                Source-IP=$si; \
                                Source-Port=$sp; \
                                Canonical-URI=$avp(s:can_uri); \
                                Billing-Party=$avp(s:billing_party); \
                                Divert-Reason=$avp(s:divert_reason); \
                                X-RTP-Stat=$hdr(X-RTP-Stat); \
                                Contact=$hdr(contact); \
                                Event=$hdr(event); \
                                SIP-Proxy-IP=$avp(s:sip_proxy_ip); \
                                ENUM-TLD=$avp(s:enum_tld)")

modparam("auth_aaa","aaa_url","radius:/usr/local/etc/radiusclient-ng/radiusclient.conf")
modparam("auth", "rpid_prefix", "<sip:")
modparam("auth", "rpid_suffix", "@77.66.2.137>;screen=yes;privacy=off")
#modparam("auth", "rpid_suffix", "@203.215.179.54>;screen=yes;privacy=off")
modparam("auth", "rpid_avp", "$avp(s:rpid)")
#modparam("uri","service_type",10)


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

modparam("dispatcher", "db_url", "mysql://opensips:opensipsrw@localhost
/opensips")
modparam("permissions", "db_url", "mysql://opensips:opensipsrw@localhost
/opensips")

#----------------- setting NAT module parameters ---------------------

modparam("nathelper","ping_nated_only",1)
modparam("nathelper", "natping_interval", 30)
modparam("nathelper","natping_processes",1)
#modparam("nathelper","rtpproxy_sock","udp:127.0.0.1:7890")
modparam("nathelper","received_avp","$avp(i:42)")
#modparam("nathelper", "sipping_bflag", 7)
modparam("usrloc", "nat_bflag", 6)

route{

        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }

        #NAT detection
        log("######################################### Go to Route 3 for NAT
Detection #####################################");
        route(3);

        if (has_totag()) {
                # sequential request withing a dialog should
                # take the path determined by record-routing
                if (loose_route()) {
                        if (is_method("BYE")) {
                                setflag(1); # do accounting ...
                                setflag(3); # ... even if the transaction
fails
                        } else if (is_method("INVITE")) {
                                record_route();
                        }

                        route(1);
                } else {

                        if ( is_method("ACK") ) {
                                if ( t_check_trans() ) {
                                        t_relay();
                                        exit;
                                } else {
                                        exit;
                                }
                        }
                        sl_send_reply("404","Not here");
                }
                exit;
        }

        #initial requests

        # CANCEL processing
        if (is_method("CANCEL"))
        {
                if (t_check_trans())
                        t_relay();
                exit;
        }

        t_check_trans();

        if (loose_route()) {
                xlog("L_ERR",
                "Attempt to route with preloaded Route's
[$fu/$tu/$ru/$ci]");
                if (!is_method("ACK"))
                        sl_send_reply("403","Preload Route denied");
                exit;
        }

        # record routing
        if (!is_method("REGISTER|MESSAGE"))
                record_route();

        $avp(s:checksrc) = check_source_address("0");

log("###########################################################################################\n");
        xlog("Check Source Address from Address TABLE Where Value 1 is Equal
to True: $(avp(s:checksrc))\n");

log("###########################################################################################\n");
        if (is_method("INVITE") && check_source_address("0")) {

               if(uri=~"^sip:4569918004@*"){

                    log("####################INVITE####################");

                    rewriteuser("3225555002");
                    setflag(1); # do accounting

                    log("#################INVITE ENDS##################");
        }

        }
        else
        {
                log("################CALL REJECTED##################");
                #t_reply("405","Forbidden");
        }


        if (!uri==myself)
        {
                append_hf("P-hint: outbound\r\n");
                route(1);
        }

        # requests for my domain


        if(uri==myself)
        {
                log("########################################### URI ==
MYSELF  ########################################");
                if(method=="REGISTER")
                {
                        route(2);
                }

                append_hf("P-hint: usrloc applied\r\n");
        }


        if (is_method("PUBLISH"))
        {
                sl_send_reply("503", "Service Unavailable");
                exit;
        }


        if (is_method("REGISTER"))
        {
                route(2);
        }

        if ($rU==NULL) {
                # request with no Username in RURI
                sl_send_reply("484","Address Incomplete");
                exit;
        }


        # apply DB based aliases (uncomment to enable)
        ##alias_db_lookup("dbaliases");

        # do lookup with method filtering
        if (!lookup("location","m")) {
                switch ($retcode) {
                        case -1:
                                log("############################# LOOKUP
LOCATION FLAG -1 PASS #################################");
                                #ds_select_dst("1","4");

                                log("############################# DO
ACCOUNTING ON RADIUS ######################################");
                                setflag(2);

                                log("############################# SEND CALL
TO ASTERISK  #######################################");
                                rewritehostport("11.22.33.45:5070");

                                #forward();
                                log("############################# CALL IS
GOING IN STATEFULL MANNER ############################");
                                t_relay();

                                log("############################# CALL
ROUTING TO ROUTE 1 ######################################");
                                route(1);
                                exit;

                        case -3:
                                log("############################ LOOKUP
LOCATION FLAG -3 PASS #################################");
                                t_newtran();
                                t_reply("404", "Not Found");
                                exit;
                        case -2:
                                log("############################ LOOKUP
LOCATION FLAG -2 PASS #################################");
                                sl_send_reply("405", "Method Not Allowed");
                                exit;
                }
        }

        # when routing via usrloc, log the missed calls also
        setflag(2);

        route(1);
}

route[1] {
        # for INVITEs enable some additional helper routes
        if (is_method("INVITE")) {

                log("################################ INVITE ROUTE 1
Function ##################################");

                t_on_branch("2");
                t_on_reply("2");
                t_on_failure("1");
        }

        if (subst_uri('/(sip:.*);nat=yes/\1/')){

                log("################################  IF SUBSTR CONTAINS
NAT=YES ################################");
                setbflag(6);
        };

        if (isflagset(5)||isbflagset(6)) {

                log("################################  CHECK FLAGSET AND
ROUTE TO 4 ###############################");
                route(4);
        }


        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
}
route[2]
{
        log("######################################## AAA-REGISTRATION
#######################################");
        if (!aaa_www_authorize("11.22.33.44"))
        {
                www_challenge("11.22.33.44", "1");
                 return;
                #    #exit;
        }
        #else
        #{
        #       t_reply("405","UnAuhorized");
        #       exit();
        #}

        if(isflagset(5))
        {
                log("###################################  IF FLAG SET IS 5
##################################");
                # set branch flag -- when someone will call this user
                # the INVITE will have branch flag 6 set after
lookup("location")
                setbflag(6);
                # if you want OPTIONS natpings uncomment next
                # setbflag(7);
        }


        if (!save("location"))
                sl_reply_error();

        exit;
}

route[3]
{
        log("################################ FUNCTION ROUTE 3 NAT
DETECTION  ################################");

        force_rport();
        if (nat_uac_test("19")) {
                if (method=="REGISTER") {
                        fix_nated_register();
                } else {
                        fix_nated_contact();
                };
        setflag(5);
        };
}
route[4]
{
        log("################################ FUNCTION ROUTE 4 RTP PROXY
################################");
        if (is_method("BYE")) {
                unforce_rtp_proxy();
        } else if (is_method("INVITE")){
                force_rtp_proxy();
                #t_on_failure("2");
                t_on_failure("3");
        };
        if (isflagset(5))
                search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
        #t_on_reply("1");
        t_on_reply("3");
}



branch_route[2] {
        xlog("new branch at $ru\n");
}


onreply_route[2] {
        xlog("incoming reply\n");
}


failure_route[1] {
        if (t_was_cancelled()) {
                exit;
        }
failure_route[3] {

        log("################################ FAILURE ROUTE 3 FUNCTION
################################");

        if (isbflagset(6) || isflagset(5)) {
                unforce_rtp_proxy();
        }
}

onreply_route[3] {

        log("################################ ONREPLY ROUTE 3 FUNCTION
################################");

        if ((isflagset(5) || isbflagset(6)) &&
status=~"(183)|(2[0-9][0-9])") {
                force_rtp_proxy();
        }
        search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');

        if (isbflagset(6)) {
                fix_nated_contact();
        }
        exit;
}

Further more to add when I call within UAS means call between 2 registered
softphones on OpenSIPs 2 way audio is heard, but when calling from DID one
way audio is passing through, caller can hears the UAC which is registered
on OpenSIPs but UAC can't hears the caller. Note: OpenSIPs is hosted on
public IP and UAC are located on different network behind the Nat.

Please assist me to resolve this problem. Waiting for your reply.

-- 
Regards,

Ahmed Munir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20100503/6397ded0/attachment-0001.htm 


More information about the Users mailing list