[SR-Users] Subscribe and PUA database

Misha Ketslah thezogg at gmail.com
Tue Jan 29 16:49:17 CET 2013


Hello, i'm trying to set BLF on my snom 320 phone to get notification on
function key for certain extension as well registered against kamailio.
Any other info i can provide except the following one and as well i want to
exuse me, as i'm pretty noob to all this, and my question might be silly,
but after hours in front of google i found no solution :)

I always get that:

  after pua_set_publish()  **
 3(7825) ERROR: *** cfgtrace: c=[/usr/local/etc/kamailio/kamailio.cfg]
l=791 a=16 n=if
 3(7825) ERROR: *** cfgtrace: c=[/usr/local/etc/kamailio/kamailio.cfg]
l=780 a=41 n=isflagset
 3(7825) ERROR: *** cfgtrace: c=[/usr/local/etc/kamailio/kamailio.cfg]
l=799 a=16 n=if
 3(7825) ERROR: *** cfgtrace: c=[/usr/local/etc/kamailio/kamailio.cfg]
l=791 a=25 n=save
 3(7825) ERROR: pua [send_publish.c:578]: New PUBLISH and no body found-
invalid request
 3(7825) ERROR: pua_usrloc [ul_publish.c:326]: while sending publish
 3(7825) ERROR: pua_usrloc [ul_publish.c:327]: TEST: type &
UL_CONTACT_UPDATE is 2, and error is -1
 (^^^ This line was added by me into module as i saw related thread and the
patch solution, though it never meets condition and fails to insert from
there as well.)
 3(7825) ERROR: *** cfgtrace: c=[/usr/local/etc/kamailio/kamailio.cfg]
l=799 a=2 n=exit



my configs are :
in BLF i set

<sip:666 at SERV_IP;user=phone>

in cfg i have



alias="SERV_IP"
listen=udp:SERV_IP
port=5060

loadmodule "db_mysql.so"

loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "alias_db.so"
loadmodule "speeddial.so"

...

modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 3)
modparam("usrloc", "use_domain", MULTIDOMAIN)
...

modparam("presence", "db_url", DBURL)
modparam("presence", "subs_db_mode" , 3  )
#modparam("presence", "publ_cache", 0)
modparam("presence", "expires_offset", 300)
modparam("presence", "max_expires", 3600)
#modparam("presence", "force_active", 1)
modparam("presence", "db_update_period", 10)
modparam("presence", "server_address", "sip:SERV_IP:5060")


modparam("presence_xml", "db_url", DBURL)
modparam("presence_xml", "force_active", 1)
#modparam("presence_dialoginfo", "force_single_dialog", 1)

modparam("pua", "db_url" ,DBURL )
modparam("pua", "db_mode", 2)
modparam("pua", "db_table", "pua")
#modparam("pua", "outbound_proxy", "sip:SERV_IP")
modparam("pua", "min_expires", 10)
modparam("pua", "default_expires", 3600)
modparam("pua", "update_period", 60)
modparam("pua_usrloc", "default_domain", "SERV_IP")

request_route {




if(method=="NOTIFY")
    {
           xlog("  pua_update_contact  $rm from $fu  (IP:$si:$sp)  \n");

        if(!pua_update_contact())
             xlog("pua update failed \n");



    }



    # per request initial checks
    route(REQINIT);

    # NAT detection
    route(NATDETECT);

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

    # handle requests within SIP dialogs
    route(WITHINDLG);

    ### only initial requests (no To tag)

    t_check_trans();

    # authentication
    route(AUTH);





    route(SPEEDDIAL);



    # record routing for dialog forming requests (in case they are routed)
    # - remove preloaded route headers
    remove_hf("Route");
    if (is_method("INVITE|SUBSCRIBE"))
        record_route();

    # account only INVITEs
    if (is_method("INVITE"))
    {
        setflag(FLT_ACC); # do accounting
    }

    # dispatch requests to foreign domains
    route(SIPOUT);

    ### requests for my local domains

    # handle presence related requests
    route(PRESENCE);

    # handle registrations
    route(REGISTRAR);

    if ($rU==$null)
    {

        # request with no Username in RURI
        sl_send_reply("484","Address Incomplete");
        exit;
    }

    # dispatch destinations to PSTN
    route(PSTN);




route(DISPATCH);



    # user location service
    route(LOCATION);

    route(RELAY);
}


route[RELAY] {

    # enable additional event routes for forwarded requests
    # - serial forking, RTP relaying handling, a.s.o.
    if (is_method("INVITE|SUBSCRIBE")) {
        t_on_branch("MANAGE_BRANCH");
        t_on_reply("MANAGE_REPLY");
    }
    if (is_method("INVITE")) {
        t_on_failure("MANAGE_FAILURE");
    }

    if (!t_relay()) {
        sl_reply_error();
    }
    exit;
}

# Per SIP request initial checks
route[REQINIT] {
#!ifdef WITH_ANTIFLOOD
    # flood dection from same IP and traffic ban for a while
    # be sure you exclude checking trusted peers, such as pstn gateways
    # - local host excluded (e.g., loop to self)
    if(src_ip!=myself)
    {
        if($sht(ipban=>$si)!=$null)
        {
            # ip is already blocked
            xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
            exit;
        }
        if (!pike_check_req())
        {
            xlog("L_ALERT","ALERT: pike blocking $rm from $fu
(IP:$si:$sp)\n");
            $sht(ipban=>$si) = 1;
            exit;
        }
    }
#!endif

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

    if(!sanity_check("1511", "7"))
    {
        xlog("Malformed SIP message from $si:$sp\n");
        exit;
    }
}

# Handle requests within SIP dialogs
route[WITHINDLG] {
    if (has_totag()) {
        # sequential request withing a dialog should
        # take the path determined by record-routing
        if (loose_route()) {
            route(DLGURI);
            if (is_method("BYE")) {
                setflag(FLT_ACC); # do accounting ...
                setflag(FLT_ACCFAILED); # ... even if the transaction fails
            }
            else if ( is_method("ACK") ) {
                # ACK is forwarded statelessy
                route(NATMANAGE);
            }
            else if ( is_method("NOTIFY") ) {
                # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
                record_route();

            }
            route(RELAY);
        } else {
            if (is_method("SUBSCRIBE") && uri == myself) {
                # in-dialog subscribe requests
                route(PRESENCE);
                exit;
            }
            if ( is_method("ACK") ) {
                if ( t_check_trans() ) {
                    # no loose-route, but stateful ACK;
                    # must be an ACK after a 487
                    # or e.g. 404 from upstream server
                    t_relay();
                    exit;
                } else {
                    # ACK without matching transaction ... ignore and
discard
                    exit;
                }
            }
            sl_send_reply("404","Not here");
        }
        exit;
    }
}

# Handle SIP registrations
route[REGISTRAR] {

    if (is_method("REGISTER"))
    {
        xlog("pua_set_publish()\n");

        if(!pua_set_publish())
            xlog("set publish failed  \n");


        xlog(" after pua_set_publish()\n");
            if(isflagset(FLT_NATS))
        {
            setbflag(FLB_NATB);
            # uncomment next line to do SIP NAT pinging
            ## setbflag(FLB_NATSIPPING);
        }




        #pua_set_publish();
        if (!save("location"))
        {
            sl_reply_error();
            xlog("save location failed \n");

        }


        exit;

}
}

# USER location service
route[LOCATION] {

#!ifdef WITH_SPEEDIAL



if(uri=~"sip:[0-9]{2}@.*")



    xlog("speeddials\n");

    # search for short dialing - 2-digit extension
    if($rU=~"^[0-9][0-9]$")
    if(sd_lookup("speed_dial"))
            route(SIPOUT);
#!endif

#!ifdef WITH_ALIASDB
    # search in DB-based aliases
    if(alias_db_lookup("dbaliases"))
        route(SIPOUT);
#!endif

    $avp(oexten) = $rU;
    if (!lookup("location")) {
        $var(rc) = $rc;
        route(TOVOICEMAIL);
        t_newtran();
        switch ($var(rc)) {
            case -1:
            case -3:
                send_reply("404", "Not Found");
                exit;
            case -2:
                send_reply("405", "Method Not Allowed");
                exit;
        }
    }

    # when routing via usrloc, log the missed calls also
    if (is_method("INVITE"))
    {
        setflag(FLT_ACCMISSED);
    }
}

# Presence server route
route[PRESENCE] {
    if(!is_method("PUBLISH|SUBSCRIBE"))
        return;


    # search for short dialing - 2-digit extension
    if($rU=~"^[0-9][0-9]$")
        sd_lookup("speed_dial");

    route(SPEEDDIAL);



xlog("PUBLISH|SUBSCRIBE");


    sl_send_reply("100","trying");
    if (!t_newtran())
    {
        sl_reply_error();
        exit;
    };
    append_to_reply("Contact: <sip:82.80.18.100:5060>\r\n");
    if(is_method("PUBLISH"))
    {
        xlog("handle publish here\n");

        handle_publish();
        t_release();
    }
    else
    if( is_method("SUBSCRIBE"))
    {
         handle subscribe here \n");

        handle_subscribe();
        t_release();
    }
    exit;
}

# Authentication route
route[AUTH] {
#!ifdef WITH_AUTH

#!ifdef WITH_IPAUTH
    if((!is_method("REGISTER")) && allow_source_address())
    {
        # source IP allowed
        return;
    }
#!endif

    if (is_method("REGISTER") || from_uri==myself)
    {
        # authenticate requests
        if (!auth_check("$fd", "subscriber", "1")) {
            auth_challenge("$fd", "0");
            exit;
        }
        # user authenticated - remove auth header
        if(!is_method("REGISTER|PUBLISH"))
            consume_credentials();
    }
    # if caller is not local subscriber, then check if it calls
    # a local destination, otherwise deny, not an open relay here
    if (from_uri!=myself && uri!=myself)
    {
        sl_send_reply("403","Not relaying");
        exit;
    }

#!endif
    return;
}

# Caller NAT detection route
route[NATDETECT] {
#!ifdef WITH_NAT
    force_rport();
    if (nat_uac_test("19")) {
        if (is_method("REGISTER")) {
            fix_nated_register();
        } else {
            add_contact_alias();
        }
        setflag(FLT_NATS);
    }
#!endif
    return;
}

# RTPProxy control
route[NATMANAGE] {
#!ifdef WITH_NAT
    if (is_request()) {
        if(has_totag()) {
            if(check_route_param("nat=yes")) {
                setbflag(FLB_NATB);
            }
        }
    }
    if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
        return;

    rtpproxy_manage();

    if (is_request()) {
        if (!has_totag()) {
            add_rr_param(";nat=yes");
        }
    }
    if (is_reply()) {
        if(isbflagset(FLB_NATB)) {
            add_contact_alias();
        }
    }
#!endif
    return;
}

# URI update for dialog requests
route[DLGURI] {
#!ifdef WITH_NAT
    if(!isdsturiset()) {
        handle_ruri_alias();
    }
#!endif
    return;
}

# Routing to foreign domains
route[SIPOUT] {
    if (!uri==myself)
    {
        append_hf("P-hint: outbound\r\n");
        route(RELAY);
    }
}

# PSTN GW routing
route[PSTN] {
        .......

    return;
}

# XMLRPC routing

route[XMLRPC] {
    ....
}
#!endif

# route to voicemail server
route[TOVOICEMAIL] {
......
    return;
}

# manage outgoing branches
branch_route[MANAGE_BRANCH] {
    xdbg("new branch [$T_branch_idx] to $ru\n");
    route(NATMANAGE);
}

# manage incoming replies
onreply_route[MANAGE_REPLY] {
    xdbg("incoming reply\n");
    if(status=~"[12][0-9][0-9]")
        route(NATMANAGE);
}

# manage failure routing cases
failure_route[MANAGE_FAILURE] {
    route(NATMANAGE);

    if (t_is_canceled()) {
        exit;
    }

#!ifdef WITH_BLOCK3XX
    # block call redirect based on 3xx replies.
    if (t_check_status("3[0-9][0-9]")) {
        t_reply("404","Not found");
        exit;
    }
#!endif

}







route[SPEEDDIAL] {
.....
    return;
    }


....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130129/9a733d7f/attachment-0001.htm>


More information about the sr-users mailing list